Michael Philip's Blog

Writing about MS Tech with strong focus on Azure & CRM

Execute Workflow Programatically Using .Net In Microsoft Dynamics CRM 2011

Leave a comment

Problem:   Suppose you have a CRM workflow but at certain condition you want to execute it by code.

Solution:
You will just need to get the Workflow ID and then you use the below code:
-How to get Workflow ID ?

1.  Go to settings =>  Processes

2. Open your Workflow.

selectworkflow

3. Select  its ID from the URL as the screenshot describe.

WorkFlowID

Code:

IOrganizationService _service;

//Create the request
ExecuteWorkflowRequest request = new ExecuteWorkflowRequest()
{
WorkflowId = “Workf Guid”,
EntityId = “The Guid of the record  on-which you would like to execute the workflow”
};

// Execute the workflow.
ExecuteWorkflowResponse response =
(ExecuteWorkflowResponse)_service.Execute(request);

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s