PL 400 : read entity change records by using platform APIs (Implement data synchronization)

We have discussed about Change tracking in the previous article. It has given information about the behavior and its usefulness. As is known, change tracking is used for the purpose of synchronizing the data by identifying the data changes that have occurred since the last data synchronization. It provides the efficient and reliable mechanism to determine what records had changed in Dataverse.


Before the read the changes for a table, make sure that the change tracking feature is enabled in that table. Either developers can change from Table UI or programmatically by setting the ChangeTrackingEnabled property to True.

Delta links:

According to the OData 4.0 documentation, delta links are "opaque, service-generated links that the client uses to retrieve subsequent changes to a result". Microsoft has built this standard into change tracking in Dataverse to provide a common, standard method for interfacing with change data as it occurs over time. After issuing a change tracking request, our response will contain a delta link, which we will then pass to our next request to get changes that have occurred since the initial request.

Read changes in tables by using the Web API:

After enabled change tracking on an table, we can retrieve its changes through the Web API by adding odata.track-changes as a preference header in web request. On the initial request, we will receive the entire set of data that applies to the query because a delta has not been applied. However, the response will show an @odata.deltaLink value. This link contains a Dettatoken parameter which is intended to be passed into subsequent when we want to see what changes have been applied since this query was run.


Code:

{

          "@odata.context":"[Organization URI]/data/v9.0/$metadata#accounts(name,telephone1,fax)/$delta",

          "@odata.deltaLink":"[Organization URI]/api/data/v9.1/accounts?$select=name,telephone1,fax&$deltatoken=919058%2108%2f22%2f2017%2008%3a21%3a20",

"value":

    [

        {

            "@odata.etag":"W/\"915244\"",

            "name":"Monte Orton",

            "telephone1":"555000",

            "fax":"10101",

            "accountid":"60c4e274-0d87-e711-80e5-00155db19e6d"

        },

        {

            "@odata.context":"[Organization URI]/api/data/v9.0/$metadata#accounts/$deletedEntity",

            "id":"2e451703-c686-e711-80e5-00155db19e6d",

            "reason":"deleted"

        }

    ]

}


Courtesy :

Change Tracking 


Comments

Popular posts from this blog

Exploring the Differences: Managed vs. Unmanaged Solutions in Dynamics CRM/Dataverse

PCF vs. Web Resources: Choosing the Right Extensibility Tool for Dataverse

Effective Strategies for Debugging Plugins in Dynamics CRM