Dynamics CRM 2016 – Using SetProcessRequest message to update your Business Process programmatically

Exploring new stuffs in Dynamics CRM 2016 is great and if it is something technical and gives me an opportunity to write some code, it’s like icing on the cake for me.

CRM 2016 has introduced the new SetProcessRequest message which enables you to set the business process of a target entity. So let’s get into some action here.

I will demo this with the opportunity entity. The opportunity entity has a default process of “Opportunity Sales Process”. Below is the opportunity record loaded with the same business process.



So I created another business process flow for the opportunity entity called “Opportunity Business Process Flow” I will switch the business process of the record for the above record to this new process.

var service = GetService();

            SetProcessRequest req = new SetProcessRequest();
            req.Target = new EntityReference("opportunity",Guid.Parse("7059510E-59A3-E511-80E4-3863BB35AD90"));
            req.NewProcess = new EntityReference("process", Guid.Parse("AEC906DF-5C10-490D-8D0E-E5620FAAE614"));

            var resp = service.Execute(req);


So once we open the record again, the new process is loaded.



So what about the workflows or plugins registered on change of processid of your application? SetProcessRequest will fire the update message and any workflows registered on change of processid would trigger.

Happy exploring CRM 2016.

About Debajit
I am a Dynamics CRM Most Valuable Professional (MVP) with 12 years of experience in Microsoft .NET Technologies and 9 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

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 )

Google photo

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

Connecting to %s

%d bloggers like this: