Use Messages (Request and Response Classes) with the Execute Method

[Applies to: Microsoft Dynamics CRM 2011]

The IOrganizationService provides methods to perform common operations. In addition to the common methods, methods, you can use the IOrganizationService.Execute method to execute messages that are not exposed as methods.The Execute method takes a message request class as a parameter and returns a message response class. Request message class names end with "Request" and response message class names end with "Response". For more information about all messages supported by the Execute method, see xRM Messages in the Organization Service, CRM Messages in the Organization Service . The IDiscoveryServiceand the IDeploymentService Web services use a similar execute request and response pattern.

Execute message flow

OrganizationRequest is the base class for all messages requests. You can use this base class to execute any messages, specifying the message name and the parameter collection for the request. However, when you use a derived class, such as AssociateRequest, the parameter collection is populated when you use the properties on the request class.

The Execute method returns the corresponding response class for the request, a derived class of the OrganizationResponse class. As with the request class, the derived class contains a property for each value in the results parameter collection. All messages have a response, but many do not have any properties on the response. .

Messages are pre-defined in metadata and stored as records in the SDK message entities. For each message you can determine whether it works while connected to the server or from Microsoft Dynamics CRM for Microsoft Office Outlook with Offline Access. This information can be found in the SdkMessage.Availability attribute. For more information, see Plug-in Registration Entities for Microsoft Dynamics CRM.

Pass Optional Parameters in Messages

You can pass optional parameters to any message request by adding a value to the Parameters property. Some parameters are not exposed properties on request classes. In order to set these parameters, they must be set in the Parameters collection on the Request class.

The following table lists these parameters.


Parameter Description Messages


A String that specifies the unique name of the solution to which the operation applies. For more information, see Dependency Tracking for Solution Components.



Specifying this parameter is no longer required. The match codes used to detect duplicates are calculated synchronously regardless of the value passed in this parameter. For more information, see Run Duplicate Detection.



A Boolean used to disable duplicate detection on a create or update operation. For more information, see Run Duplicate Detection.


The following sample shows how to pass an optional parameter:

Account target = new Account();
target.Name = "Fabrikam";

CreateRequest req = new CreateRequest();
req.Target = target;
req["SuppressDuplicateDetection"] = true;
req["CalculateMatchCodeSynchronously"] = true;
req["SolutionUniqueName"] = "MySolutionName";

CreateResponse response = (CreateResponse)_service.Execute(req);

See Also

Microsoft Dynamics CRM 2011
Send comments about this topic to Microsoft.
© 2013 Microsoft Corporation. All rights reserved.

Community Additions