Microsoft Dynamics CRM 2013 Application New Features - Access Teams

Difference between Web API, Organization service and Organization Data service in Microsoft Dynamics CRM

Web API

Web API is introduced with Microsoft Dynamics CRM 2016 and will provide parity with the Organization service.

Key points about Web API:

  • Web API provides parity with Organization service with some limitations.
  •  It implements  OData (Open Data Protocol) version 4.0 which is an open standard for building and consuming RESTful APIs over rich data sources like DOC, HTML and PDF.
  • Because Web API is built on open standards therefore it's no necessary to use Microsoft Dynamics CRM provided libraries, third-party libraries can be used to generate classes. 
  • You can compose own Http requests as well. 
  • Wep API supports wide variety of programming languages (including .Net, C++, Java, JavaScript, Python), platforms and devices as compared to Organization service.
  • Web API will gradually replace Organization service and Organization Data service to become single web service for Microsoft Dynamics CRM.
  • Wep API Request and Response have JSON format, so its very easy to work with Wep API from JavaScript.
  • Authentication is provided by the application itself when used within web resources, form scripts and ribbon commands. 
  • Maximum 5000 records can be return for each request.

Organization Service

Organization service is available since Microsoft Dynamics CRM 2011 and is mainly used for server side development i.e. code running on Microsoft Dynamics CRM server.

Key points about Organization service:

  • Implements IOrganizationService interface.
  • Organization service is also know as SOAP endpoint.
  • Microsoft Dynamics CRM uses Windows Communication Foundation (WCF) to SOAP endpoint.
  • It is the primary web service for accessing data and metadata from Microsoft Dynamics CRM organization.
  • It is built on WCF and optimized for use with the .Net.
  • Organization service request and response has SOAP format.
  • Microsoft Dynamics CRM SDK provides assemblies and tools to generate strongly typed classes and proxies to simplify developement in Microsoft Visual Studio.
  • Maximum 5000 records can be returned in a single query.

Organization Data Service

Organization Data service is available since Microsoft Dynamics CRM 2011 and is mainly used for client side development (code running in browser)  using JavaScript. 

It supports JSON format for request and response which can be easily handled from JavaScript, therefore this is preferred service for client side development.  

Key points about Organization Data service:

  • It is preferred service for client-side development.
  • Organization Data service is also known as "OData" or "REST" endpoint.
  • Microsoft Dynamics CRM uses Windows Communication Foundation (WCF) to provide REST-based service.
  • It supports JSON and ATOM format.
  • Organization Data service can be used within Web resources, form scripts and ribbon commands.
  • Authentication is provided by the application itself, no need to write authentication code.
  • It implements OData v2 standard.
  • It is deprecated with Microsoft Dynamics CRM 2016, Web API should be used to support Microsoft Dynamics CRM 2016 and future versions.
  • It can return maximum 50 records in a single retrieve operation.
  • It is much fatser as comared to Organization service, because less bytes in JSON message in comparison to SOAP message.

 

Images in Microsoft Dynamics CRM

MS CRM Notes


Images in Microsoft Dynamics CRM

Images in Dynamics CRM are snapshot of record in SQL server, before and after the core system operation.

Pre-Image

Pre-Image, returns the image of the record as is stored in the SQL database before the CRM Platform action has been performed.

Post-Image

Post-Image, returns the image of the record as is stored in the SQL database after the CRM Platform action has been performed.

Message Stage Pre-Image Post-Image
Create PRE No No
Create POST No Yes
Update PRE Yes No
Update POST Yes Yes
Delete PRE Yes No
Delete POST Yes No

Example Usage:

  • Comparison of record before and after the operation to build custom audit functionality.
  • In update operation get value of attributes in plugin which are not changed.
  • To improve performance by avoiding retrieve query to Dynamics CRM.

Msxrmtools.com

What's New in CRM 2011 Session 2: Charts and Dashboards

Dynamics CRM 2011 : Customization

Record Type: Currency

Currency

  • One default currency is defined for organization.
  • Multiple currencies manages conversion rates.
  • For Multiple currencies all transaction recorded in base currency

Understanding Entity Change Tracking in Microsoft Dynamics CRM

In CRM integration projects, your business requirements often dictate that you should only retrieve those transaction records that have been recently created or modified in your source system since last integration. When your CRM system is the source, you would typically use CRM FetchXML query to pull data from the CRM system by comparing the record's modifiedon field, which is not a solution that is reliable enough and may not perform well when the source entity has a significant number of records.

To address this particular challenge, CRM Online 2015 Update 1 release introduced the Change Tracking feature, which offers a reliable and efficient way to track transactional data changes for CRM entities.

Turn on Change Tracking

In order to track data changes of a particular entity, you have to first turn on "Change Tracking" option for the entity. You would do so by going to the entity's customization page, and tick "Change Tracking" option under "Data Services" section.

Retrieve Changes

After Change Tracking has been enabled for the entity, you can use CRM SDK RetrieveEntityChangesRequest message to pull changes from CRM server. The following is a snippet that demonstrates how to pull changes from the CRM server.

 using (var service = new OrganizationService(crmConnection))
{
var request = new RetrieveEntityChangesRequest();

// Set which entity to get changes for.
request.EntityName = "account";
request.Columns = new ColumnSet("accountnumber", "name", "creditlimit");

// Set paging preferences.
request.PageInfo = new PagingInfo() { Count = 5000, PageNumber = 1 };

// Set change token returned from last pull.
request.DataVersion = changeToken; // set to null or remove this line to do an initial pull

// Get the changes.
var response = (RetrieveEntityChangesResponse)service.Execute(request);

// TODO: Process all the changed records (see the code snippet below)

// Save the token somewhere for future use
changeToken = response.EntityChanges.DataToken;
Console.WriteLine(changeToken);
}

Walk through Changes

After retrieving the changes, you will get two types of results. The first type of result is the newly added or updated records, and the second one is for the records that have been deleted since the last pull.

// Replace the TODO line in the above snippet with the following code
foreach (var change in response.EntityChanges.Changes)
{
if (change.Type == ChangeType.NewOrUpdated)
{
var changedItem = (NewOrUpdatedItem)change;
Entity newOrChangedEntity = changedItem.NewOrUpdatedEntity;
// TODO: Process new or updated entity record
}
else if (change.Type == ChangeType.RemoveOrDeleted)
{
var deleteditem = (RemovedOrDeletedItem)change;
EntityReference deletedEntityReference = deleteditem.RemovedItem;
// TODO: Process deleted entity records
}
}

Note that the returned NewOrChangedEntity is an instance of Entity class, while the RemovedItem (the deleted record) is an instance of EntityReference class.

Some Closing Notes

There are a few things that you should be aware when using this feature:

  • The "Change Tracking" option is an entity-level setting. It has to be enabled for the entity before you can use RetrieveEntityChangesRequest to pull data. If the option is not enabled, and you try to use this feature, you will get an error message telling you "Entity: account isn't enabled for change tracking" where account can be any entity name that you are working with.
  • Due to the fact that the "Change Tracking" option works at entity level, you would need to keep track of the change token for each entity individually. There is no organization level tracking token.
  • There is one special situation that you should watch out for. Suppose there is a newly added record after last pull and it was deleted before the new pull, you will get the record in the Delete result set, which you may not have knowledge about it.
  • In the case that you have selected to return a lookup field, the field's Name property is not returned.
  • When change collection has more records than the page size that you have specified, you would have to page through the change collection.
  • Based on my preliminary testing, it appears that CRM keeps multiple token versions, which is really nice. However, I imagine keeping too many versions on the server side would not make sense as each version would consume a certain amount of database space. There must be a limit in terms of how many versions are kept on the CRM server side. It could be either a time-based limit (say 90 days probably, which could still be a lot of change versions if I keep pulling from the server every 30 seconds) or a number-based limit. This is something that has yet to be confirmed.
  • When you retrieve changes using this feature, you will get the records in their current status, the old values before the change are not returned.
  • The user account needs to have organization level read (or so-called "Root Read") privileges for the concerned entity in order to uses RetrieveEntityChangesRequest to retrieve changes.
  • More details about this feature can be found at the CRM SDK documentation page: Use change tracking to synchronize data with external systems.

Installation of Microsoft Dynamics 2013 on a Windows 2012 Server

How to rename button in CRM 2011?

  1. Create a solution add the entity what you want and export it and extract it xml designer.
  2. Then navigate into the location RibbonDiffXml next add the customaction tag by specifying id and location and sequence.
  3. Next add button by specifying the id, command, sequence, Alt, label text, image 16 and 32, templatealias, tooltip title and description under the tag CommandUIDefinition>
  4. Next define the template with lable, tooltip text, description.

Data Importing - Microsoft Dynamics CRM 2011

This video goes through:

  • Best Practices for setting up your data for import
  • Using the data import tool in Dynamics CRM 2011
  • Using the Data Management tools to check the results of your import