CRM 2011 – Firing a workflow from a plugin

one of my favourite CRM bloggers Jamie Miley wrote a very interesting article today – How to execute a workflow from .NET and Jscript.

Jamie is always a big fan of doing anything in Jscript but I prefer the .NET approach.  You should read the article above to see both the .NET and Jscript examples and Jamie explains what’s going on and how it works.

Basically you need to instantiate a service object, which you can get pretty easily if you are in a plugin and then you can execute a workflow.  You will need the Guid of the workflow and the guid of the entity you want the workflow to run against.

First in C#:

ExecuteWorkflowRequest req = new ExecuteWorkflowRequest(); 

//specify the guid of the 
workflow req.WorkflowId = new Guid("D009C04F-F826-4B3B-90CD-209581CFC2FF"); 
//specify the guid of the related entity instance 
req.EntityId = new Guid("A46FA1C1-E38D-E011-86BA-1CC1DEE8EA49"); 
ExecuteWorkflowResponse resp = (ExecuteWorkflowResponse)slos.Execute(req); 

excellent blog post

One thought on “CRM 2011 – Firing a workflow from a plugin

Leave a Reply

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

You are commenting using your 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