14 Sep’15

Dynamics CRMCRM 2015 Update 1 – Change Tracking Feature

What is Change Tracking?

Change Tracking feature is introduced in CRM 2015 Spring update, to retrieve the changes occurred in Entity records. It helps to keep data synchronized between CRM and other systems in a performant way. This feature is very helpful in building incremental load ETLs packages.

How it works?

How Change Tracking Works

Where this feature can be useful?

If you have external systems where you take backup of CRM data, by using this feature you can build logic to only get updated data instead of pulling all the data. By doing this overall execution of ETL will be reduced drastically.

Things to be considered while using this feature

  1. Only one entity will be tracked in retrieve changes, this means, if your record contains lookup to another entity, then changes in the another entity will not be tracked while retrieving changes for this entity.
  2. The validity of Token is 90 days. The token expires after every 90 days and new request after 90 days will be considered as fresh request resulting in retrieving all the data.
  3. This feature does not track intermediate changes. For e.g., if you are tracking an Account entity changes, and if a record updates 3-4 times before you request for entity changes, it will retrieve only latest value.
  4. Records are retrieved in the order determined by server side logic. Usually, created/updated records are retrieved before deleted records. For e.g., if 200 records are updated/created and 50 are deleted, then entity collection of 250 records will be retrieved where first 200 records are either updated/created and remaining are deleted.

How to use/enable Change Tracking?

  1. Enable Change Tracking on entity you want track.

    How to Enable Change Tracking for Entity

    Note: This feature is available only for online organizations which are updated to CRM 2015 Update 1. On-Premise environments do not have this feature at this point.

Sample Code

string token;

// Initialize page number.
int pageNumber = 1;
List<Entity> initialrecords = new List<Entity>();

// Retrieve records by using Change Tracking feature.
RetrieveEntityChangesRequest request = new RetrieveEntityChangesRequest();
request.EntityName = _customBooksEntityName.ToLower();
request.Columns = new ColumnSet("sample_bookcode", "sample_name", "sample_author");
request.PageInfo = new PagingInfo() { Count = 5000, PageNumber = 1, ReturnTotalRecordCount = false };


// Initial Synchronization. Retrieves all records as well as token value.
Console.WriteLine("Initial synchronization....retrieving all records.");
while (true)
{
    RetrieveEntityChangesResponse response = (RetrieveEntityChangesResponse)_serviceProxy.Execute(request);

    initialrecords.AddRange(response.EntityChanges.Changes.Select(x => (x as NewOrUpdatedItem).NewOrUpdatedEntity).ToArray());
    initialrecords.ForEach(x => Console.WriteLine("initial record id:{0}", x.Id));
    if (!response.EntityChanges.MoreRecords)
    {
        // Store token for later query
        token = response.EntityChanges.DataToken;
        break;

    }
    // Increment the page number to retrieve the next page.
    request.PageInfo.PageNumber++;
    // Set the paging cookie to the paging cookie returned from current results.
    request.PageInfo.PagingCookie = response.EntityChanges.PagingCookie;
}
Written by

Team Member

CloudFronts

2 thoughts on “CRM 2015 Update 1 – Change Tracking Feature”

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

Want to streamline your business processes?

  • This field is for validation purposes and should be left unchanged.

Recent Articles

  • Reading more then 10K records in D3FOE OData API

    11 July’ 2018

    Introduction: We all know Dynamics 365 Finance and Operations has limitation of 10K records to be fetched at a time usi...

    Read more
  • Paging in D365 Customer Engagement v9.0

    10 July’ 2018

    Introduction: The Xrm.retrieveMultipleRecords method is used to retrieve a collection of records in Dynamics 365 Custom...

    Read more
  • Set up Dynamics 365 connection in Microsoft Social Engagement

    10 July’ 2018

    Introduction: This blog explains how to Set up Dynamics 365 connection in Microsoft Social Engagement. Steps to be follo...

    Read more
  • Voice of the Customer failed to install

    10 July’ 2018

    Introduction: Many people face issues in installing Voice of Customer solution on v9 environment and trying repeatedly ...

    Read more
  • Scribe Insight AX as a Web Service Find Block issue

    10 July’ 2018

    Introduction: If we need to look up for any value from AX then we do it by using a Find Block in Scribe Insight Eg: Basi...

    Read more