Dynamics CRM 2011 provides event-driven server side programming model. This facilitates creation of Plug-ins and Processes (aka Workflows). To use CRM Entity information within custom code the Dynamics CRM 2011 platform exposes web services. The options available to use CRM data include use of SDK assembilies (preferred approach) or Service references.
There are two major Web Services exposed by Dynamics CRM 2011 viz., IOrganizationService and IDiscoveryService
To view the service URL’s go to Settings > Customization > Developer Resources
IOrganizationService: Provides a set methods to perform operations on system and custom entities. The methods include:
- Create,Retrieve (aka Read), Update, Delete
- Associate: To create a link between two records that participate in a relationship
- Disassociate: To delete the link between two records.
IDiscoveryService: Useful in multi-tenant environments to get the organization information that a user belongs to. It provides a single method (Execute). The Execute method implements a Request/Response message exchange pattern. The base class for Request is DiscoveryRequest and the base class for Response is DiscoveryResponse.
Example: RetrieveOrganizationResponse Execute(RetrieveOrganizationRequest request)
For interacting with the CRM entities Dynamics 2011 platform supports Early-Bound and Late-Bound programming types.
- Early-Binding: Strong type-support and references are checked at compile time. CrmSvcUtil.exe is used to generate the early-bound classes so they can be utilized in the custom code.
Example: [org]_[customentity] myentity = new [org]_[customentity] ();
myentitiy.Field = “Value”;
- Late-Binding: Typically used when we have to work with unknown entities / attributes. Entity class is used which is the base class for all types of entities.
Example: Entity myEntity = new Entity(“CustomEntity”);
myEntity[“FielName”] = “Value”;