This documentation is archived and is not being maintained.

ExecuteWorkflow Message (CrmService)

Dynamics
banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Works for all deployment typesWorks online only

Executes a workflow.

The relevant classes are specified in the following table.

TypeClass
RequestExecuteWorkflowRequest
ResponseExecuteWorkflowResponse
Entityworkflow

Remarks

To use this message, pass an instance of the ExecuteWorkflowRequest class as the request parameter in the Execute method.

To perform this action, the caller must have access rights on the workflow entity instance. For a list of required privileges, see ExecuteWorkflow Privileges.

Example

[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 an ExecuteWorkflow request.
ExecuteWorkflowRequest request = new ExecuteWorkflowRequest();

//Assign the ID of the workflow you want to execute to the request.         
request.WorkflowId = new Guid("b050f053-6968-dc11-bb3a-0003ffbad37a");

//Assign the ID of the entity to execute the workflow on to the request.
request.EntityId = new Guid("1DCDEE97-35BB-44BE-8353-58BC36592656");

// Execute the workflow.
ExecuteWorkflowResponse response = (ExecuteWorkflowResponse)service.Execute(request);
[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 an ExecuteWorkflow request.
Dim request As New ExecuteWorkflowRequest()

'Assign the request the ID of the workflow we want to execute.         
request.WorkflowId = new Guid("b050f053-6968-dc11-bb3a-0003ffbad37a");

'Assign the request the ID of the entity to execute the workflow on.
request.EntityId = new Guid("1DCDEE97-35BB-44BE-8353-58BC36592656");

' Execute the workflow.
Dim response As ExecuteWorkflowResponse = CType(service.Execute(request), ExecuteWorkflowResponse)

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show: