แก้ไข

แชร์ผ่าน


Enable change tracking for entities

Note

Community interest groups have now moved from Yammer to Microsoft Viva Engage. To join a Viva Engage community and take part in the latest discussions, fill out the Request access to Finance and Operations Viva Engage Community form and choose the community you want to join.

By using change tracking, you can incrementally export data from finance and operations apps by using Data management. In an incremental export, you export only records that changed. To enable incremental export, enable change tracking on entities. If you don't enable change tracking on an entity, you can only enable a full export each time.

You can enable change tracking for both bring your own database (BYOD) and non-BYOD scenarios. This capability includes retrieving record changes through Dataverse virtual entities.

Note

Change tracking tracks record deletion only for bring your own database (BYOD) and Dataverse virtual entity use cases, if the entity supports it. Other non-BYOD scenarios don't include tracking record deletion. Deletion is tracked only for the root data source in the entity.

Enable change tracking for BYOD

You can enable change tracking when you publish one or more entities to a data store (BYOD).

  1. In the Data management workspace, select Configure entity export to database.

  2. Select the database to export data to, and then select Publish.

    You can publish one or more entities to your database. Select Show published only to see a list of entities that you previously published.

  3. Select an entity that you published, and then select Change tracking.

  4. Select the appropriate option for change tracking for your environment.

    An entity can use more than one table. These options specify the granularity at which you can track changes in an entity.

    Option How changes are tracked
    Enable primary table Changes to any fields in the primary table trigger a change in the entity. Changes to fields in secondary tables don't trigger a change in the entity.
    Enable entire entity Changes to any fields in any table in the entity trigger a change in the entity.
    Enable custom query Uses a custom query that identifies the tables on which changes must be tracked. The custom query is defined in the entity.

    Note

    If a change triggers change tracking, the change is tracked on the entire record and not at the field level. The entire entity record is exported to the destination. Regardless of the option that you select, the number of fields in the entity is the number that is exported to the destination.

Enable change tracking for non-BYOD scenarios

You can enable change tracking for non-BYOD scenarios. This feature includes retrieving record changes through Dataverse virtual entities for finance and operations apps. When you enable change tracking for an entity, you can retrieve changes through the entity's OData endpoint by adding odata.track-changes as a preference header.

For more information on using change tracking for an entity, see Use change tracking to synchronize data with external systems.

To enable change tracking for non-BYOD scenarios:

  1. From the Data management workspace, select the Data entities list page.
  2. Select the entity for which you want to enable change tracking.
  3. Select the Change tracking action on the action ribbon, and select the desired option for how changes should be tracked for the entity. See the table in the Enable change tracking for BYOD section for detail on the available options.

Custom query for change tracking

The following example shows how to add a static method to an entity. Make sure that the method returns a query, and that the root node is the same as the entity. For example, for the Customer entity, the root node is custTable, and the change tracking query for its also custTable.

  • Enable change tracking on the tables that are part of the query.
  • Create a join between the entity and the change tracking query (on the root table) to determine which records changed in the entity.
public static Query defaultCTQuery()
{
 Query q = new Query();    
    
 QueryBuildDataSource custDs = q.addDataSource(tableNum(CustTable));

 QueryBuildDataSource partyDs = custDs.addDataSource(tableNum(DirPartyTable));
 partyDs.relations(true);

 QueryBuildDataSource locationDs = partyDs.addDataSource(tableNum(DirPartyLocation));
 locationDs.addRange(fieldNum(DirPartyLocation, IsPrimary)).value(queryValue(NoYes::Yes));        
 locationDs.addLink(fieldNum(DirPartyTable, RecId), fieldNum(DirPartyLocation, Party));

 QueryBuildDataSource addressDs = locationDs.addDataSource(tableStr(LogisticsPostalAddress));        
 addressDs.addLink(fieldNum(DirPartyLocation, Location), fieldNum(LogisticsPostalAddress, Location));

 return q;
}