D365 F&O: Architecting BI Entities for Long-Term Retention Archiving

Architecture, integration and automation · 8 min read
TL;DR: Architecting custom D365 F&O data archiving requires mapping system fields to specific names like SysDataAreaId and SysRecId within BI entities to satisfy the Archive service metadata contract.
D365 F&OArchitectureData ManagementDataverseTroubleshooting

As Dynamics 365 Finance & Operations environments mature, the sheer volume of historical transactional data can degrade system performance and escalate storage costs. Microsoft's long-term retention (LTR) archive service provides a governed solution for moving this data out of the primary SQL database while keeping it accessible for reporting. However, architecting custom archiving pipelines requires a strict adherence to metadata contracts, specifically concerning how system fields are mapped in Business Intelligence (BI) entities.

You will learn how to configure these custom BI entities to comply with the Archive service requirements, ensuring that your long-term data remains discoverable and that archive jobs do not fail due to metadata mismatches. This post focuses on the crucial mapping of system fields like SysDataAreaId and the configuration of the PrimaryCompanyContext property, which are the most common points of failure in custom LTR implementations.

At a glance

  • 🔹 Applies to: Dynamics 365 Finance & Operations (10.0.x) and Dataverse-integrated environments.
  • 🔹 Prerequisites: Archive service enabled in Feature Management, Dataverse environment linked, and developer access to Visual Studio.
  • 🔹 Effort level: Medium; requires X++ metadata changes and synchronization.
  • 🔹 Outcome: Fully functional custom BI entities that support automated long-term retention without job failures.

How it works

The D365 F&O Archive service operates as a microservice outside the core AOS (Application Object Server). It interacts with your data through specialized entities known as BI entities. Unlike standard Data Management Framework (DMF) entities, BI entities used for archiving act as a strict schema contract between the F&O SQL database and the long-term storage in Dataverse. Because the archive service is designed to handle massive datasets across various Microsoft services, it expects a standardized set of system columns to manage partitioning, multi-tenancy, and row identification.

When you create a custom BI entity for archiving (typically following the [TableName]BiEntity naming convention), you cannot simply expose the standard SQL field names for system metadata. The archive service specifically looks for fields prefixed with Sys. For example, the standard DataAreaId field, which identifies the legal entity in F&O, must be mapped to an entity field named SysDataAreaId. If the service cannot find these specific names, the archive job creation will fail because the service cannot verify the data's structural integrity or its company-specific context.

LTR Archiving Metadata Pipeline
Figure 1: LTR Archiving Metadata Pipeline
Standard Table FieldRequired BI Entity Field NamePurpose in Archive Service
DataAreaIdSysDataAreaIdLegal entity partitioning and security context.
RecIdSysRecIdUnique row identification for the archive store.
PartitionSysPartitionIdData isolation across environment partitions.
TableIdSysTableIdMetadata identification for the source table.
ModifiedDateTimeSysModifiedDateTimeTracking data changes for incremental archiving.
CreatedDateTimeSysCreatedDateTimeEstablishing the age of the record for retention logic.

Step-by-step solution

1. Identify and Prepare the Custom Table

Before creating the entity, ensure your custom table has the CreatedDateTime and ModifiedDateTime properties set to Yes. These fields are essential for the archive service to determine which records fall within the retention window (e.g., records older than 5 years).

2. Create the BI Data Entity

In Visual Studio, create a new Data Entity. Use the naming convention [YourTableName]BiEntity. Set the Data Management Enabled property to No, as these entities are primarily for the Archive service and Dataverse virtual entity exposure, not for standard Excel imports.

3. Map System Fields with Mandatory Names

This is the most critical step. Drag the system fields from your table to the entity's Fields node. You must rename them manually in the entity field properties. Map DataAreaId to SysDataAreaId, RecId to SysRecId, and so on, following the table provided in the "How it works" section. Do not leave them with their default SQL names.

4. Configure Field Visibility

Select all fields in your BI entity and set the Visibility property to Public. Even fields that you would normally keep internal for security or logic reasons must be public for the archive service to successfully ingest the data into the long-term store.

5. Set the PrimaryCompanyContext

If your table is company-specific (which most transactional tables are), navigate to the entity's top-level properties. Set the PrimaryCompanyContext property to SysDataAreaId. This tells the archive service how to filter and secure data based on the legal entity during the archiving and retrieval processes.

6. Synchronize and Validate

Perform a full database synchronization to ensure the new metadata is reflected in the SQL dictionary. Once synchronized, go to System administration > Setup > Archive scenarios and attempt to add your table. If the fields are named correctly, the archive job setup will validate without errors.

Worked example

Contoso Global Logistics uses a custom table named CglCargoAudit to track historical sensor data from shipping containers. This table grows significantly over time. To maintain system performance, the architect decided to implement a long-term retention policy. The architect created an entity named CglCargoAuditBiEntity. During the development, they initially mapped the legal entity field as DataAreaId. When the IT lead tried to create the archive job in the Archive scenarios form, they received a validation error stating that the system fields were missing.

The architect corrected the entity by mapping DataAreaId to SysDataAreaId and setting the PrimaryCompanyContext to this new field. They also ensured RecId was mapped to SysRecId. After these changes, the entity metadata looked like this in the AOT:

// Entity: CglCargoAuditBiEntity
// Properties
PrimaryCompanyContext: SysDataAreaId
IsPublic: Yes

// Mappings
DataAreaId -> SysDataAreaId
RecId -> SysRecId
Partition -> SysPartitionId
SensorValue -> SensorValue
ReadingTime -> ReadingTime

Following the deployment, the archive job successfully processed the legacy records. The database size was reduced significantly, improving overall system performance. The archived data remained accessible via Power BI by connecting to the Dataverse long-term retention tables, allowing the compliance team to run audits on 5-year-old sensor data without impacting the live F&O environment.

430 GB
Storage Saved
25%
Perf Gain
100%
Compliance
Database Size Reduction via LTR
Figure 3: Impact of archiving 100 million audit records on primary SQL storage.

Automation and AI opportunities

Architecting these entities opens the door for advanced automation. You can use Power Automate to monitor the ArchiveJobEntity for failures. If a job fails due to a metadata error, the flow can extract the error message and alert the development team via Microsoft Teams. Additionally, Microsoft Copilot can be used to analyze the growth trends of your custom tables. By feeding table growth statistics into a Copilot-enabled Power BI report, you can receive proactive recommendations on which custom BI entities need to be created next to stay ahead of database capacity limits. Finally, once data is in the LTR store, AI Builder in Power Apps can be used to perform trend analysis on archived data that would be too expensive to process in the live SQL database.

Common pitfalls and troubleshooting

  • Symptom: Archive job creation fails with an error stating required system fields are missing.
    Cause: The entity fields for DataAreaId or RecId are named standardly (e.g., "DataAreaId") instead of using the "Sys" prefix.
    Fix: Rename the entity fields to SysDataAreaId and SysRecId in Visual Studio.
  • Symptom: Data is archived but cannot be filtered by legal entity in the archive UI.
    Cause: The PrimaryCompanyContext property on the BI entity was left blank.
    Fix: Set PrimaryCompanyContext to SysDataAreaId and redeploy.
  • Symptom: BI entity is not visible in the Archive scenarios setup form.
    Cause: The entity's IsPublic property is set to No or the suffix is not BiEntity.
    Fix: Ensure IsPublic is Yes and the naming convention is strictly followed.
  • Symptom: Archive service fails to identify which records to archive.
    Cause: The source table does not have CreatedDateTime or ModifiedDateTime enabled.
    Fix: Enable these properties on the table level and update the BI entity mapping.
  • Symptom: Field visibility errors during ingestion.
    Cause: Some system fields were set to Private visibility within the entity.
    Fix: Set the Visibility property to Public for all fields in the entity.

Best-practice checklist

  • ✅ Always use the BiEntity suffix for entities intended for the archive service.
  • ✅ Map DataAreaId to SysDataAreaId for every company-specific table.
  • ✅ Set PrimaryCompanyContext to SysDataAreaId to ensure data security in the archive.
  • ✅ Ensure RecId is mapped to SysRecId to prevent row identification conflicts.
  • ✅ Verify that IsPublic is set to Yes for the entity and all its fields.
  • ✅ Include SysCreatedDateTime and SysModifiedDateTime to support age-based retention rules.
  • ✅ Run a full database sync after any change to BI entity field names.
  • ✅ Test the archive scenario in a sandbox environment before deploying to production.
BI Entity Configuration Summary
Figure 2: BI Entity Configuration Summary

FAQ

Why can't I just use my existing OData entities for archiving?

Standard OData entities often include complex business logic, virtual fields, and unmapped datasources that the Archive service cannot process efficiently. BI entities are designed to be lightweight, direct mappings that the archive microservice can use to perform high-speed data movement without triggering AOS-level overhead.

Does renaming the fields to SysDataAreaId affect my X++ code?

No. These names only exist at the entity metadata layer. Your X++ code and the underlying SQL table still use the standard DataAreaId name. The mapping only changes how the Archive service and Dataverse perceive the field.

What happens if I forget to map the SysPartitionId?

In most modern D365 F&O cloud environments, there is only one partition. However, the archive service metadata validator often requires the field to be present to satisfy the schema contract. Omitting it can lead to validation warnings or failures during the archive job initialization.

Key takeaways

  • 🎯 The D365 F&O Archive service requires a specific metadata contract where system fields must be prefixed with Sys (e.g., SysDataAreaId).
  • 🎯 Setting the PrimaryCompanyContext to SysDataAreaId is mandatory for company-specific data to ensure correct partitioning in the long-term store.
  • 🎯 BI entities for archiving must have all fields set to Public visibility, even if they are not intended for external user access.
  • 🎯 Properly architected BI entities prevent job failures and enable seamless integration with Power Platform for historical reporting.

Further reading

Note: written with AI assistance. Always validate in a sandbox environment before applying to production.

Comments

Popular posts from this blog

Monthly Inventory Close in Microsoft Dynamics AX 2012

Product Configuration Technology Ax2012R3

How to configure Fixed Assets Module in Ax2012