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.