CRM 2013 introduced some excellent functionality, one that has been covered not long ago were Business Rules, but another piece was the arrival of Business Process Flows. I could imagine some people’s initial reactions where How do i hide them? as one of the most noticeable ones was on the Lead to Opportunity Process. However, they can be used very well in the right scenario, especially to enforce a specific business process. One of the major drawbacks though, like Business Rules, was the inability to branch based on user input. You could include multiple entities in the linear process, however if something didn’t suit a user had to manually select ‘switch process’ and then know which secondary process to continue with based on resulting data.

However, Business Process Flows have since been greatly improved in the 2015 release. Did you ever read those ‘Choose your own Adventure’ books as a kid? Where at certain points you could make the decision and go to a certain page number based on your choice.. well that is what I think of when I look at Business Process Flows now. They are capable of not just enforcing a companies linear business process anymore, but also a dynamic one based on user input and choices.

The User Interface has also been improved, as you can see in the screenshot below, to look much like Business Rules so if you are familiar with them you’ll know what to expect. The two most notable things I am going to discuss are:

  • Add Branch Option
  • Insert Stage after branch Option

These options can be found underneath the boxes of the process.


Add Branch Option

Both of these options are new for 2015, firstly the ‘Add Branch Option’ allows you include conditions based on selections in the record, not necessarily the fields included in the Business Process Flow.  An example is I have a BPF on the Case entity that has 4 fields in the first stage and choose to add a branch, I don’t just have those 4 fields to select from on my condition. This is really useful as it means your condition is not encapsulated to your BPF, meaning you don’t have to put what could be unnecessarily fields inside it, potentially leading to clutter and confusion of the user. You might need to create a condition if certain SLA’s are in effect for example, but this doesn’t need to appear on the flow itself.

A second important point to consider about branching is you can stack your conditions so have AND/OR just like Business Rules, however the same rule applies: You cannot have both an AND & OR in one condition. If you were to add an AND condition, then add a second OR in the same condition it changes your first AND to an OR automatically so you only have an ‘OR’ in your condition – this is why you need to be aware of that.

So once you have added your condition, you can then automate the staging so they are taken to a certain stage if your condition is met as true, however take them to a different stage if it is false. You can then continue branching out from there.


Insert Stage after branch Option

The second point above is regarding the ‘Insert Stage After Branch Option’ – this option is important as it’s how you get back to the main business flow – I would recommend as best practice, unless its on purpose by design, to not have a single stage Business Process Flow – they are not really worth it, if there are fields you need to enforce your better off using Business Rules – You can put conditional logic on those so a business process flow isn’t really required here.  So if you are using conditional logic, it’s important that you select ‘Insert Stage after Branch’ at least once so you can build another stage into your BPF in case your conditional logic proves to evaluate to false.

New JavaScript for 2015

2015 has also introduced some new JavaScript controls to assist in the Business Process Flow manipulation – these are:

The JavaScript functionality, described in the CRM 2015 SDK is quite interesting as it does give an additional edge from what is capable in the user interface. I’ve listed the main actions below however the full list can be found in the CRM 2015 SDK here.(The specific area where it discusses JavaScript controls for BPFs is titled ‘Write Scripts for Business Process Flows)

  • Change the process where there are more than one processes available for the entity (pays attention to security roles)

So you know I mentioned before about CRM 2013 you can ‘Switch Process’ to change to an entirely new Business Process Flow – this still applies however this could now be automated using JavaScript in CRM 2015. This gives you even more power as not only can you now branch and add conditional logic based on dynamic input, but based on that input, you can now change to an entirely different process that is available to that entity – (remember there are limits per entity) – but imagine the span you now have as they allow cross entity business process flows – they are only registered against the primary entity so you can then switch to a new business process that is available to an additional entity. In my opinion, this is one of the best things you could do with JavaScript – and it even pays attention to security roles, bonus! 😉 An example from the CRM 2015 SDK is in the featured image of this post.

  • Move to the next stage when all required steps are completed

As opposed to a user selecting ‘next stage’ you could automate this for them

  • Move to the previous stage and make it the current active stage (backtrack)

This is an interesting one, even though you have progressed past a step, based on future input, you could force a user to go back a stage to re-evaluate the data that was originally input. A nice twist, perhaps could be used  to increase data integrity but also breaks that old linear flow of left to right, perhaps a field didn’t have to be completed in an stage 1, but in stage 2 if something is entered, it could force the user to go back to the stage to complete it perhaps.

  • Hide the process control

Making it easier to hide the process control on those enabled out of the box

  • Query the full Business Process Flow Logic that is not currently visible (including any branching logic that is hidden)

An interesting one – this could be used not only for forward conditional logic but past conditional logic, so you could evalulate more than one of the users choice automatically to perhaps display messages to the user, set statuses etc – something you might want to do in the background and automate as opposed to adding a new condition in the flow.

Two new events you can choose from to execute your code:

  • OnStageChange event: when the active stage of a business process flow changes
  • OnStageSelected event: when a stage is selected

It is also worth noting that with these JavaScript functions there is no place new to put them via the user interface and and need to be used in the form OnLoad event.

Demo Play

I had a play around with hiding the process control on the case entity. All I used is one line:


I put this in a single function, no parameters, in a js web resource on the main Case form, added the event onLoad for the form with the name of my function and this is the result:


This was a very simple example and it’s likely you’ll want to add a bit more logic. Also, a drawback I noticed when testing this is you can see the process when it renders it for about 1-2 seconds then it disappears. It doesn’t bother me but it’s worth noting.

In some following posts I’ll be demonstrating more of this functionality using the improved Business Process Flows in the UI and also through JavaScript.