Dynamics 365 Business Central: How to automatically archive sales orders via AL (For example, Archive on Order Release)
This post explains how to automatically archive sales orders in Business Central when they are released using AL code. It covers the standard archiving capabilities for sales documents and demonstrates how to extend automatic archiving beyond the built-in triggers by subscribing to the release event and calling the ArchiveManagement codeunit.

post Dynamics 365 Lab
"In Business Central, you can archive sales, purchase, and service orders, quotes, return orders, and blanket orders."
Key points
- Business Central allows archiving of sales, purchase, service orders, quotes, return orders, blanket orders, and projects multiple times with each archive creating a new version
- Standard automatic archiving triggers exist for status changes, document deletion, printing/sending, quote-to-order conversion, and posting
- Adding custom automatic archiving triggers like order release requires AL code using event subscribers to extend beyond built-in functionality
- The ArchiveManagement codeunit’s StoreSalesDocument method enables programmatic archiving without showing confirmation dialogs
- Archived sales documents can be restored to overwrite the original if it still exists and is unposted
Quotes
- “In Business Central, you can archive sales, purchase, and service orders, quotes, return orders, and blanket orders.” (Establishes the scope of archivable document types, helping users understand what can be archived in the system)
- “We can use the following standard method. codeunit 5063 ArchiveManagement -> StoreSalesDocument” (Provides the practical solution approach using existing platform APIs without requiring full custom implementation)
AL objects mentioned
As named in the post. A name that matches one object page by exact type and name links to it; the others stay as named.
- codeunit 5063 “ArchiveManagement”
- codeunit 414 “Release Sales Document”
- codeunit “ArchiveEventHandler”
- page “Archived Sales Orders”
- page 459 “Sales & Receivables Setup”
Not found in BC28-30: codeunit “ArchiveEventHandler”, page “Archived Sales Orders”.
Context
- Features: automatic archiving, document archiving, sales order archiving, event subscribers, archive restoration
Source: Dynamics 365 Lab - Yun Zhu, community blog. Summary, key points and quotes are derived (CONTENT-NOTICE.md); read the original for the full text.