CrmService.Execute Method
The Execute method executes a message that either represents a specialized method or specific business logic.
Syntax
[Visual Basic]
Public Function Execute(
ByVal Request As Request
) As Response
[C#]
public Response Execute(
Request Request
);
[JScript]
public function Execute(
Request : Request
) : Response;
Parameters
Request
Specifies a specific Request instance.
Return Value
Returns an instance of a Response. You must cast the return value of the Execute method to the specific instance of the response that corresponds to the Request parameter.
Remarks
To perform this action, the caller must have the necessary privileges to the entity type specified in the request class. The caller must also have access rights on the entity instances specified in the request class.
Example
The following example demonstrates the use of the Execute method.
[C#]
// Set up the CRM service.
CrmService service = new CrmService();
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
// Create the request object.
AddItemCampaignRequest add = new AddItemCampaignRequest();
// Set the properties of the request object.
add.CampaignId = campaignId;
add.EntityId = productId;
add.EntityName = EntityName.product;
// Execute the request.
AddItemCampaignResponse added = (AddItemCampaignResponse) service.Execute(add);
[Visual Basic .NET]
' Set up the CRM service.
Dim service As New CrmService()
service.Credentials = System.Net.CredentialCache.DefaultCredentials
' Create the request object.
Dim add As New AddItemCampaignRequest()
' Set the properties of the request object.
add.CampaignId = campaignId
add.EntityId = productId
add.EntityName = EntityName.product
' Execute the request.
Dim added As AddItemCampaignResponse = CType(service.Execute(add), AddItemCampaignResponse)
See Also