How to Preserve Sales Document Attachments When Posting Fails in Dynamics 365
Question details
Users need to retain attachments linked to the Sales Header when a document posting fails in Dynamics 365, instead of having the files automatically deleted upon reopening.

- Product
- Microsoft Dynamics 365
- Device & OS
- not provided
- Scenario
- Managing sales documents and transferring attachments during the invoice posting process.
- Observed behavior
- Attachments transfer successfully to the Sales Invoice Header upon a successful posting, but are deleted if the posting fails and the sales document reopens.
Ensure you have developer privileges in Dynamics 365 to review and modify extension logic related to attachment handling.
Modify Posting Transaction Logic in Dynamics 365 Extensions
Adjust your extension code to keep attachments linked to the Sales Header during a rollback, ensuring they are only moved upon successful posting.
When a posting fails, the transaction rolls back, which can orphan or delete attachments if the transfer logic isn't properly sequenced. By modifying the extension, you can delay the transfer until a success confirmation is received.
Open your Dynamics 365 development environment and navigate to the extension managing the posting transaction.
Locate the transaction logic that handles the Sales Header Attachment FactBox and observe when the transfer triggers.
Configure the code so that attachments remain firmly linked to the Sales Header if the posting fails and the document reopens.
Set the logic to transfer or copy attachments to the Sales Invoice Header only after a successful posting confirmation is received.

Manage Your Business Document Attachments Seamlessly with WPS Office
While Dynamics 365 manages your ERP transactions, you need a reliable suite to create, edit, and review the actual sales attachments (like invoices, contracts, and spreadsheets). WPS Office offers a free, lightweight, and highly compatible alternative to Microsoft Office for all your business documentation needs.
- 1. Download and Install: Get WPS Office for free from the official website and install it on your computer.
- 2. Open Business Attachments: Use WPS to seamlessly open and edit .docx, .xlsx, or .pdf files exported from Dynamics 365.
- 3. Save and Re-attach: Save your optimized files and attach them directly to your Dynamics 365 Sales Header securely.

Frequently Asked Questions
Why do my attachments disappear when a posting fails in Dynamics 365?
If the transaction rolls back due to a failure, temporary links created during the posting process might be cleared. Adjusting the extension code prevents them from being dropped before the transaction succeeds.
Can I recover attachments deleted by a failed posting?
If the files were permanently deleted during the system rollback and not saved locally, they generally need to be re-attached manually. Keeping local backups of important sales documents before posting is highly recommended.
Where can I get specialized developer help for Dynamics 365 posting logic?
You can seek specialized assistance from Microsoft MVPs and experienced developers in the official Dynamics 365 Community forums (community.dynamics.com).




