Copy SO - Documents  Topic is solved

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

Copy SO - Documents

Postby Riyaz » Wed Dec 23, 2020 2:24 am

Hi There

When we use the Copy function of the sales order the document record gets copied to the destination, but the file cant be opened. On checking I noticed that the FileBinary ends up as NULL for that document. I've tried to update as a plugin and via trigger but its not successful. I either get an error, or the new Sales Order wont get saved at all. Can you pls guide here.
Riyaz
Kohai
Kohai
 
Posts: 254
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2

Re: Copy SO - Documents

Postby SBarnes » Wed Dec 23, 2020 8:01 am

Given I just tried this on a demo database with the system setting to copy the documents over turned on under invoicing and you then try and open or save the document on the copied order, Jiwa produces a null reference exception I suspect you have come across a bug but Jiwa would need to confirm this as likewise in my demo database the file binary is also null for me.

If I was looking to get around this in the copy start event I would make my own copy of the documents into the sales order objects generic object collection and then in the copy end event clear the documents Jiwa had created and then add the ones back in from the data in the generic object collection by creating a new document from the old one and adding it to the documents collection.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Copy SO - Documents  Topic is solved

Postby Scott.Pearce » Wed Dec 23, 2020 8:52 am

Logged as DEV-4705.

At some point we introduced a property to the document class named "FileBinaryChanged". This was done for performance reasons - why save a potentially huge binary to the database if it hadn't actually changed? (maybe only the document Description was changed). Only when the FileBinary property is set for a document does FileBinaryChanged get set to true.

Now when a copy is performed, we simply generate a new RecID for a document and set it's InsertFlag to true. Voila. Copied. Unfortunately, we must have failed to update the copy method for documents when we introduced the FileBinaryChanged flag, so the copy does not push the file binary to the database upon save because we failed to set FileBinaryChanged to true during the copy process.

I've attached a plugin to workaround this issue. It simply sets FileBinaryChanged to true for all documents in the sales order copy end event:

Plugin Sales Order Copy Documents Fix.xml
(34.29 KiB) Downloaded 612 times
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Copy SO - Documents

Postby Riyaz » Wed Dec 23, 2020 7:37 pm

All good, thanks Scott and Stuart
Riyaz
Kohai
Kohai
 
Posts: 254
Joined: Wed Dec 02, 2015 2:05 pm
Topics Solved: 2


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests