Quantcast
Channel: Microsoft Dynamics 365 Community
Viewing all articles
Browse latest Browse all 64797

CRM 2015 Update 1 – Change Tracking Feature

$
0
0

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 initialrecords = new List();

// 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;
}

The post CRM 2015 Update 1 – Change Tracking Feature appeared first on CloudFronts - Dynamics CRM | AX | BI.


Viewing all articles
Browse latest Browse all 64797

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>