I have a problem with saving the document attachment on Sales Header while posting the document. I saved 2 attachments to the Sales Header Attachment Factbox. I did this on event "OnRunOnBeforeFinalizePosting". If the posting flow doesn't have any error the attachment are successfully saved on the Sales Invoice Heard table, but if any errors happen during the posting flow the Sales Header is reopened again but the attachments are deleted and I want the attachments to be saved when Sales Header is reopened. I also used the Commit method but if I use Commit the document will be posted even if it has any errors.
So what I want is to prevent document from being posted if while the process any errors occurs and my attachments to be saved to Sales Header attachment document.
Can anyone help with this? Thanks in advance!