Enhanced Guide: Leveraging the Document Archival Feature in Acumatica for Developers
The Document Archival Feature in Acumatica, introduced in version 2023 R1, is a robust tool designed to optimize database performance by partitioning archived and non-archived records. This guide explains how developers can implement, customize, and extend this feature for custom DACs, graphs, and screens while leveraging its powerful capabilities.
Configuring DAC and Table for Archival
To enable the archival feature, developers must modify the DAC and its associated table to include fields and attributes required for SQL partitioning. Follow these steps:
1. Add a `GotReadyForArchiveAt` field of type `DateTime` to your DAC and table.
2. Attach the `PXDBGotReadyForArchiveAttribute` to this field to enable archival readiness tracking.
3. Add a `DatabaseRecordStatus` column of type `int` to the table, with a default value of `0`. This column serves as the key for SQL partitioning.
Adding Archive and Extract Actions to Graph
The next step involves configuring the graph to support archiving and extracting operations:
1. Add `PXArchive` and `PXExtract` actions to the graph.
- These actions can be added directly to the DAC or specified through the `PXGraph<TGraph, TPrimary>` class.
2. Ensure the primary DAC is correctly linked to the graph to activate these actions on the screen.
Updating the GotReadyForArchiveAt Field
The archival process relies on the `GotReadyForArchiveAt` field to determine when records are ready for archiving. You can use a custom action, such as `MakeReadyForArchive`, to populate this field. Here's how:
1. Create an action that sets `GotReadyForArchiveAt` to a date that meets the retention criteria.
- For example, subtract 35 days from the current date to simulate readiness when testing.
2. This action is crucial for triggering the archival process, as Acumatica enforces the retention period defined in the Archival Policy.
Archiving Documents and SQL Partitioning
After setting up the archival policy and updating the `GotReadyForArchiveAt` field, you can archive documents:
1. Use the `Archive` button on the custom screen (enabled once `GotReadyForArchiveAt` has a date that has already passed ).
2. Upon archiving, the `DatabaseRecordStatus` column value changes from `0` to `1`, indicating that the record is now archived.
3. Archived records are excluded from regular lookups and inquiries but remain accessible via direct links or keys.
Extracting Documents from the Archive
To unarchive a document, use the `Extract` action available on the custom screen:
1. This action resets the `DatabaseRecordStatus` column to `0`.
2. The document becomes operable again and is included in active lookups and inquiries.