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.

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.

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.

Execute messages in the background (asynchronously)

In addition to executing message requests immediately, as is the case with calling Execute and passing a message request, you can also choose to execute a message request in the background (asynchronously). This improves system performance by postponing message execution until some later time when the server load may be less. Interactive users do not have to wait for the target message to execute before they can continue. This is especially useful when processing messages that take a few minutes or more to execute.

Use the ExecuteAsyncRequest message to execute a message asynchronously. You configure the request and pass the request instance as an argument to Execute. ExecuteAsyncResponse returns with the ID of the asynchronous job. You can (optionally) query the job using the ID to find out its current state.

You can also execute multiple messages at a time using the ExecuteMultipleRequest message. To do this, add one or more ExecuteAsync message requests to an ExecuteMultiple message request. Due to throttling restrictions that improve overall system performance, only one message running asynchronously is allowed to execute at a time for each organization. You cannot execute an ExecuteMultiple message request from an ExecuteAsync message request. For more information about the ExecuteMultiple message request, see Use ExecuteMultiple to improve performance for bulk data load.