Skip Setting a Business process flow during record create in Dynamics 365/ CDS? This simple trick may help you

Follow my blog for more interesting topics on Dynamics 365, Portals and Power Platform. For training and consulting, write to us at info@xrmforyou.com

We all love Business Process flows. And why not? Their introduction have solved the age old problem of visualizing a record as and when it progress through multiple stages. Typically lead and opportunity moving through multiple stages, a product moving through multiple stages of development and numerous other examples can be cited.

And yet there can be scenarios where you need to skip applying business process when the record is created. Typical example may be bulk importing records from some other sources where you are not sure about what business process need to be applied and you want the decision to be left to end-users when they work with the respective records. Really there can be scenarios which you never thought.

I've never thought about it like that before | Honest about my faith

In scenarios like this, how do you plan to do the same. After all the default business process flow configured for an entity is automatically applied when you create new record for the entity.

We know for every entity there is a field called ProcessId. You may be wondering, isn’t it deprecated. Yes it is deprecated. However as much surprising it is, the same will come to help in scenarios like this.

All we need to do in this case is set the ProcessId field to Guid.Empty. That’s all.

And how are you going to do it. Well there can be many ways but in our scenario if it is bulk import, we can have a plugin in pre-operation stage where we will set the value of ProcessId to Guid.Empty.

Something like this shall work.

public class SetProcessIdToBlank : IPlugin
    {
       public void Execute(IServiceProvider serviceProvider)
       {
          var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
          var target = (Entity)context.InputParameters["Target"];

         target["processid"] = Guid.Empty;
       }
    }

And now the records shall be created without any Business process flow record.

Hope this helps!

Debajit Dutta

(Microsoft MVP)

Published by

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