Document RecID  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Document RecID

Postby SBarnes » Fri Mar 26, 2021 4:00 pm

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;
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Document RecID  Topic is solved

Postby Mike.Sheen » Wed Apr 21, 2021 1:03 pm

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.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests