Enable change tracking for entities - D365FO

Everything about Change tracking in D365FO


Topics attended in this Post:

1. How to enable change tracking for BYOD
2. How to enable change tracking for NON-BYOD
3. Example to create a custom change tracking for Entities through coding
4. Limitation for change tracking

1. 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 PublishYou can publish one or more entities to your database. Select Show published only to see a list of entities that have previously been published.

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

  4. Select the appropriate option for change tracking for your environment. An entity can be modeled by using more than one table. The options let you specify the granularity at which changes can be tracked in an entity.

2. Enable change tracking for non-BYOD scenarios

Change tracking can be enabled for non-BYOD scenarios. This includes retrieving record changes through Dataverse virtual entities for Finance and Operations apps. When change tracking is enabled for an entity, changes can be retrieved 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 above for detail on the available options.
3.  Example to create a custom change tracking for Entities through coding

This Enable custom query is an option we have, to get change tracking enabled for as many as tables we need. It is similar to X++ custom queries. We have to start by adding data source of Entity's base table.

public static Query defaultCTQuery()
    {
        Query ctQuery = new Query();

        QueryBuildDataSource qbdsEcoResProduct =  ctQuery.addDataSource(tableNum(EcoResProduct));

        QueryBuildDataSource qbdsInventTable = qbdsEcoResProduct.addDataSource(tableNum(InventTable));
        qbdsInventTable.relations(true);

        return ctQuery;
    }

4. Limitation for change tracking
    a. Enable Primary Table: Primary table shouldn't be a view. Change tracking doesn't work for views.
 
    b. Enable Custom Change tracking: We can customize change tracking by adding as many related tables we need. 
        i. Adding view in Custom query is of no use for change tracking
        ii. Adding data sources in  defaultCTQuery() method should start with adding Entity's primary/base table.


Comment if you need any other details on change tracking.

Let us know if this helps and share others :)


Post a Comment

0 Comments

Contact Form