Export (0) Print
Expand All
Expand Minimize

SetStateWorkflow Message (CrmService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Works for all deployment typesWorks online and offline

Sets the state of a workflow.

The relevant classes are specified in the following table.

TypeClass
RequestSetStateWorkflowRequest
ResponseSetStateWorkflowResponse
Entityworkflow

Remarks

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

The possible states are defined in the WorkflowState enumeration. To perform this action, the caller must have access rights on the entity instance specified in the request class. For a list of required privileges, see SetState Privileges.

This message updates the Workflow entity properties statuscode and statecode.

Example

The following code example shows how to use the SetStateWorkflow message.

[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 a request.

SetStateWorkflowRequest request = new SetStateWorkflowRequest();

// Assign the request the ID of the workflow to publish.

request.WorkflowId = new Guid("b050f053-6968-dc11-bb3a-0003ffbad37a");

// Set the state to "Published".

request.WorkflowState = WorkflowState.Published;

// Set the status to its default value.

request.WorkflowStatus = -1;

// Execute the request.

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.
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 a request 
Dim request As New SetStateWorkflowRequest()

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

' Set the state to "Published".
request.WorkflowState = WorkflowState.Published

' Set the status to it's default value.
request.WorkflowStatus = -1

' Execute the request.
service.Execute(request)

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft