Page 1 of 1

Document RecID

PostPosted: Fri Mar 26, 2021 4:00 pm
by SBarnes
I've just discovered that

Code: Select all
JiwaFinancials.Jiwa.JiwaApplication.Documents.Document doc = Inventory.Manager.CollectionItemFactory.CreateCollectionItem<JiwaFinancials.Jiwa.JiwaApplication.Documents.Document>();

does not set the RecID, it only gets set when you add it to the inventory documents collection, is this by design or a bug or am I missing something?

To clarify change the order of lines 2 and three below and the RecID doesn't end up in the custom field, ReadDocument is an extension method.

Code: Select all
 JiwaFinancials.Jiwa.JiwaApplication.Documents.Document ReadDocument = Inventory.ReadDocument(docText);
                    Inventory.Documents.Add(ReadDocument);
                    Inventory.CustomFieldValues.get_ItemFromSettingName("WCDoc" + DocNo.ToString() + "Doc").Contents = ReadDocument.RecID;

Re: Document RecID  Topic is solved

PostPosted: Wed Apr 21, 2021 1:03 pm
by Mike.Sheen
SBarnes wrote:I've just discovered that

Code: Select all
JiwaFinancials.Jiwa.JiwaApplication.Documents.Document doc = Inventory.Manager.CollectionItemFactory.CreateCollectionItem<JiwaFinancials.Jiwa.JiwaApplication.Documents.Document>();

does not set the RecID, it only gets set when you add it to the inventory documents collection, is this by design or a bug or am I missing something?


Correct. We set the RecID in the Add method of the JiwaCollection base class - but only if the RecID property is null or blank. Creating an instance (even via the Factory) of the JiwaCollectionItem does not set the RecID. We do this because there are two reasons to create a JiwaCollectionItem - either you're reading items from the database, which means the RecID will be set before adding to the collection, or you're creating the item so it can be added to the collection - and in that case we'll set the RecID for you.