Tip #589: Programmatically Move Cross Entity Business Process Flow Stages in CRM 2016

It’s been a while since we’ve heard from Gayan “Not Daddy” Perera. As often the case with Gayan’s tips, this one is a nugget.

Moving the stage of a cross entity business process flow programmatically can be achieved by using the NavigateToNextEntity request. Most of the parameters are self explanatory, the only tricky one is the NewTraversedPath parameter (New! I knew it! We blogged about TraversedPath before and it did look promising – t.j.). This is a string value containing the previous stage id and the next stage id combined together with a comma.

Here is an example. Let’s say we have a case, the next step is to review the case email which will refer to the latest email from the customer. What we’re wanting to achieve is to automatically set this stage along with the email record reference so the user doesn’t need to click Next and then to select the Email record; eliminating two additional clicks.

OrganizationRequest or = 
   new OrganizationRequest("NavigateToNextEntity");
or.Parameters.Add("ProcessId", 
   new Guid("guid of the business process flow"));

or.Parameters.Add("NewActiveStageId", 
   new Guid("guid of the next stage"));
or.Parameters.Add("CurrentEntityLogicalName", 
   "incident");
or.Parameters.Add("CurrentEntityId", 
   new Guid("{guid of the case}"));

or.Parameters.Add("NextEntityLogicalName", 
   "email");
or.Parameters.Add("NextEntityId", 
   new Guid("{guid of the email}"));
            
or.Parameters.Add("NewTraversedPath", 
   "previous stage guid,next stage guid");

var response = sdk.Execute(or) as OrganizationResponse;

Read more at the source.

Tweet about this on TwitterShare on Facebook0Share on Google+0

2 thoughts on “Tip #589: Programmatically Move Cross Entity Business Process Flow Stages in CRM 2016

  1. tim says:

    Thanks for this.

    Can this method be used for progressing stages within the entity.

    Since branching (traversedpath) I can’t work out how to pro grammatically progress stages in C# (I now this can be done client side but this is not suitable for us) – any help would be appreciated.

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *