Adding a document to a processed sales order  Topic is solved

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

Adding a document to a processed sales order

Postby SBarnes » Fri Jul 17, 2020 3:37 pm

I had asked the question about adding an attachment to an emailed order here viewtopic.php?f=26&t=1335

This works fine when firing off the email from the process end but what I would now like to be able to do is add the csv file to the documents collection on the sales order but the following code produces an error, is there any way to make this happen as it appears you can't do it through the UI either?

Code: Select all

               JiwaFinancials.Jiwa.JiwaApplication.Documents.Document sdoc = salesorder.Manager.CollectionItemFactory.CreateCollectionItem<JiwaFinancials.Jiwa.JiwaApplication.Documents.Document>();
                  sdoc.FileBinary = System.IO.File.ReadAllBytes(FileName);
                  sdoc.Description = "Invoice csv";


                    sdoc.DocumentType = salesorder.Documents.DocumentTypes.GetDefaultDocumentType();
                    sdoc.PhysicalFileName = FileName;
                  salesorder.Documents.Add(sdoc);               
               
               salesorder.Save();
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Adding a document to a processed sales order  Topic is solved

Postby SBarnes » Sun Jul 19, 2020 6:32 pm

To answer my own question here the easiest way around this ended up being in the process start event create the file attach it to the order there as well as in the email, if the process ends up failing then nothing gets attached to the order because its never saved, the emailing still needs to stay in the process end because this should only happen on success.

At the end of the day it meant creating the file twice but it's the simplest answer.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests

cron