Adding a document to a processed sales order
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?
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();