Export (0) Print
Expand All

CrmService.Execute Method

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

The Execute method executes a message that represents either a specialized method or specific business logic.

Syntax

[Visual Basic .NET]
Public Function Execute(
  ByVal Request As Request
) As Response
[C#]
public Response Execute(
  Request  Request
);

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.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
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 token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
 
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
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)

Requirements

Namespace: CrmService

See Also

Concepts

Tasks

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2015 Microsoft