top of page

Implementing Data Archiving in Dynamics 365 Business Central with Codeunit 600

Data archiving ensures that important business records remain accessible even after deletion from active use. In Dynamics 365 Business Central, this feature supports compliance requirements and maintains audit trails. Organisations handle large volumes of transactional data, such as sales orders and invoices. Proper archiving prevents loss of historical information while keeping the system performant.

Introduction to Data Archiving in Business Central

Business Central provides built-in mechanisms to archive records before removal. This process creates copies in dedicated tables or attachments. Archiving applies to modules like sales, purchases, and warehouse management. The system stores archived data in a way that allows retrieval for reporting or legal purposes.

Without archiving, deleted records disappear permanently. This approach risks non-compliance with regulations like GDPR or SOX. Archiving balances data retention needs with database efficiency. Developers customise archiving through AL code to fit specific business rules.

Overview of Codeunit 600 and Its Role

Codeunit 600, known as ArchiveManagement, handles the core logic for archiving in Business Central. It manages the creation, storage, and retrieval of archived documents. The codeunit integrates with standard deletion processes in tables like Sales Header and Purchase Header.

Key functions include ArchiveRecord, which copies data to archive tables, and GetPostedDocument, which retrieves archived versions. This codeunit ensures consistency across different document types. For example, it supports PDF attachments for visual records alongside data copies.

Microsoft designed Codeunit 600 for extensibility. Developers call its procedures from custom events or page actions. Official documentation on data archiving in Business Central details its integration with the application.

Step-by-Step Guide to Implementation

Implement Codeunit 600 by extending standard deletion logic or creating custom archiving routines. Follow these steps:

  1. Identify the Target Table: Select tables eligible for archiving, such as 36 for Sales Header. Review table properties to confirm archiving setup.

  2. Subscribe to Deletion Events: In an extension codeunit, subscribe to the OnBeforeDeleteRecord event for the target table. This triggers before standard deletion.

  3. Call ArchiveManagement Procedures: Invoke ArchiveRecord(Rec) from Codeunit 600. Pass the record variable to copy data. Example AL code:

ree

  1. Handle Attachments if Needed: Use ArchiveManagement.CreateAttachment to store files like PDFs. Link them to the archived record.

  2. Test the Setup: Delete a sample record and verify the archive in the Archived Versions factbox or related tables. Use the Navigate feature to access archived data.

  3. Configure Retention Policies: Set up data retention policies in Business Central to automate the cleanup of old archives. Access this via the Data Retention Policies page.

These steps ensure seamless integration. For advanced scenarios, combine with job queues for batch archiving.


Common Scenarios and Troubleshooting

Organisations use archiving for sales document history, purchase order audits, and inventory adjustments. In finance, archived ledger entries support year-end reporting. Warehouse scenarios involve archiving picking lists to track fulfilled orders.


Troubleshooting common issues starts with error logs.

  • If archiving fails, check permissions on archive tables.

  • Ensure the ArchiveManagement codeunit runs under appropriate user contexts.

  • Duplicate archives may occur from multiple event subscribers; consolidate extensions to avoid this.


Performance concerns arise with high-volume deletions. Optimise by archiving in batches or using asynchronous processing. Refer to performance guidelines on Microsoft's Learn site for tuning tips.


Benefits for Users and How D365 Training Can Help

Data archiving preserves critical information, reducing risks in audits and disputes. Users access historical data without cluttering live tables, improving system speed. Consultants gain efficiency in custom implementations, ensuring client compliance.

D365 Training specialises in instructor-led sessions for Dynamics professionals.


Our courses cover AL development, including Codeunit extensions. Practice managers can upskill their delivery team through tailored workshops and hands-on labs. SMB users close knowledge gaps with hands-on coaching on Business Central features like archiving.


Contact D365 Training for bespoke training that integrates data management best practices into your workflow.


Conclusion with Resources

Codeunit 600 streamlines data archiving in Business Central, supporting robust record management. Implement it to safeguard business data effectively.

Explore these resources:


Subscribe to our newsletter to receive our articles in your inbox, invites to our free training webinars and special offers for our training courses.

Comments


Viscontis Limited

Canada Street

SE16 6BH, London, UK

Company Registered in England and Wales 

© 2025 by Viscontis Limited. All rights Reserved

  • LinkedIn
IMG_4206.PNG

Legal Notice: This website is neither owned nor sponsored by Microsoft©. Any reference to Microsoft, Dynamics365, Microsoft Teams, Microsoft Business Central, Azure or any other Microsoft software is purely for illustration, training and demo purposes.

 

You must perform due diligence before purchasing, implementing and setting up any technology mentioned on this website. By navigating this website, you acknowledge that we owe no responsibility if your business experiences losses, disruption or loss of data following the implementation of suggestions, guides or training material accessed from or mentioned on this website.

bottom of page