While working on a project, we wanted to reduce the number of clicks a user had to perform in order to move to the next stage of a cross entity business process flow. A quick look around the Dynamics CRM SDK and Bing/Google came up with road blocks. It seems the only way to advance a cross entity CRM process flow was to write SQL; doable but unsupported and wouldn’t work in an Online environment anyway…

Here at Magnetism we like to think there is always a way to make things happen…if the CRM UI can do it then so can we…just a matter of figuring out the correct sequence.

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.

image

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", "guid of the previous stage,guid of the next stage"); var response = sdk.Execute(or) as OrganizationResponse;

The way these stages are kept in Dynamics CRM is via an entity called businessprocessflowinstance. This entity is not accessible through the SDK. The way to advance stages is to execute a request called NavigateToNextEntity. Most of the parameters for this request are straight forward except for NewTraversedPath. The value you must provide this parameter is a string comprised of the previous stage id and the next stage id using a comma to separate them.

Once you have executed this request, you’ll notice that the CRM cross entity business process flow has moved correctly (flag is set), however to automatically jump the form to the correct place you’ll need to use a little trick Isaac blogged few weeks ago Smile

Enjoy!