Business Process Flows: Programmatically Switch BPF in Dynamics 365 using JavaScript

The ability to branch Business Process Flows (BPFs) is a very useful component of Dynamics 365. However, there may come a time when you need to change the BPF dynamically based on a specific field on the form. BPFs currently have a limitation on the number of stages (30 max) and the number of conditional levels (5 deep). If you hit one of these limitations, it could be useful to create multiple BPFs and use JavaScript to switch between processes depending on specific field values. In today’s blog, we will cover how to change the BPF using JavaScript in the unified interface when the form loads based on a custom field Type on the Opportunity form. Let’s take a closer look!

1. Create a new attribute on the form for the field that will change the BPF. In the example below, we have a new option set field called Type with values of New and Used. On create of the Opportunity, the Type field is locked and cannot be changed after the record has been created. When the Opportunity Type has a value of Used, update the business process flow to the Opportunity Used Type BPF.


2. Create two separate BPFs for the required entity. In this case, we created two separate BPFs for the Opportunity entity.

3. From each BPF, grab the record GUID from the URL. Write the values down as they will be referenced later in the JavaScript.

Opportunity Sales Process BPF:


Opportunity Used Type BPF (used only if the Opportunity Type attribute is set to Used):


4. Create a new Script Web Resource.


5. Add the following JavaScript to the Web Resource (be sure to update the attributes and GUIDs to the values that match your requirement):

function onLoadChangeBPFByType(executionContext) {
	var formContext = executionContext.getFormContext();
	var oppTopic = formContext.getAttribute(“name”).getValue();
	var oppType = formContext.getAttribute(“jb_type”).getText();
	var activeProcessID =;
	if (oppTopic != null) {
		if (oppType == “Used” && activeProcessID.toUpperCase() != “CBB4EDDC - B4AF - 4429 - AAE0 - 8 B404E00344F”)“CBB4EDDC - B4AF - 4429 - AAE0 - 8 B404E00344F”, callBackFunction);

function callBackFunction(result) {
	if (result == “success”) {} else {}

6. Open the Opportunity Form editor and click Form properties.

7. Add the newly created JavaScript web resource to the form libraries and Event Handlers.


8. Click Save and Publish Customizations.

9. Create a new Opportunity with a Type of New and the BPF will remain set to Opportunity Sales Process.


10. Create a new Opportunity with a Type of Used and the BPF will automatically update to Opportunity Used Type once the Opportunity has been created.


11. The newly-created BPF Opportunity Used Type must be added to the unified interface apps that are to be used in your environment. In this example, we will just walk through adding the BPF to the Sales Hub.

12. In Dynamics 365, go to Settings > My Apps.

13. Click on the ellipsis next to Sales Hub, as shown below.


15. Click Components > ARTIFACTS > Business Process Flow.

16. Select the BPF you want to use in the Sales Hub app. In this example, Opportunity Used Type must be selected, as this is the newly-created BPF to be called by our JavaScript on the Opportunity form.


17. Click Save, Validate, and Publish.

BPF Branching adds a lot of flexibility, however if you run into a situation where you hit the 5 levels deep limitation or you need to create more than 30 stages, you can use the process described above to switch the process dynamically to the correct BPF.

Be sure to subscribe to our blog for more tips and tricks.

Happy Dynamics 365’ing!

Best Practices for Business Process Flows

A visual representation of business processes can add value to any organization, whether it's about working a sales opportunity to close or assisting customers through a support issue. Business process flows in Dynamics CRM are powerful tools for this purpose. In today's blog, we cover some basic best practices for working with business process flows in Dynamics CRM.

So, why use business process flows in the first place? There are many advantages to setting these up, provided that your organization already spent the effort researching and documenting key business processes after extensive requirements gathering sessions. Using business process flows can help:

Encourage user adoption and facilitate entry of key data.

Upon the creation of records with business process flows, users will see an outline of key information they need to fill out in order to keep moving forward. Users don't have to scroll down to find and enter required fields, as it's all presented on the first page. For reporting purposes, we can surface the key fields in the business process flow that management would require to run reports.

Standardize common processes.

Many organizations don't have well documented processes, and instead rely on the experience of their top performers to close sales and cases. Business process flows provide an excellent opportunity to implement the habits of those top performers and standardize it across the organization. It is important to seek out and gather the knowledge of these rock stars during the requirements gathering phase of the project.

Customize processes by user role.

Business process flows in Dynamics CRM allow system designers to show or hide processes depending on the user's role. This helps tailor the experience for sales teams that have unique steps to go through. The system can hide other irrelevant business process flows so the user is focused on the processes they need.

Get new employees up to speed with your business processes.

Some organizations have high turnover due to the nature of their industry. Implementing business process flows will help guide new employees on what their next step should be, thereby serving as their informal personal trainer. Key fields are surfaced on the business process flow
to make sure users document the most important information needed to stay productive and meet their performance numbers.

Best Practices for Configuration

After going through the design and implementation of business process flows, there are some noteworthy tips to share:

Get input from management and users on business process flow functionality.

First and foremost, it is of utmost importance to demo the business process flow
early on to your organization to receive their input on the functionality, as it will likely be a brand-new concept for many users.

Best Practices

The out-of-the-box stages available in a typical Sales business process flow for an Opportunity are:

1. Qualify

2. Develop

3. Propose

4. Close

These stages are a good starting point, but you are not limited to them as they may be renamed and new stages can be added. Custom processes that may benefit from visual stages should also be discussed and evaluated.

Chart the business process flow design by user roles.

Should the audience prove receptive to the functionality, the next step is to chart the different business process flows as needed according to the different segments of user roles. An example of this would be the need for different business process flows for unique sales business units, as they may sell different services and are evaluated according to different performance standards.

Add all required fields to the business process flow.

To facilitate data entry for users, it's beneficial to add all required fields to the business process flow for easy access. Please note that business process flows can assign some fields as required before the record can transition to the next stage.

Use business process flows as checklists.

For the initial implementation of a business process flow, it may be useful to advise the organization that they should be used as a "checklist" of sorts. This means there may fields that may not traditionally be on the record, but are exclusive to the process. These typically take the form of Yes/No fields.

If you are the system designer, don't be afraid to add custom fields that will be used exclusively for the business process flow. When creating them, it may be beneficial to prefix them with bpf to differentiate them from other fields on the database and reporting side.

Use shorter labels.

Due to size limitations of business process flows, it's important to keep concise, short labels as CRM will not display the full label if it's too long. Luckily, business process flows allow you to assign unique custom labels for each of the fields when in customization mode.

Also note that business process flows can only contain up to nine fields comfortably by stage. Any more fields than that may be overwhelming for users and may not display properly on the users screen.

Add a Stage Category to record views.

Need to add the stage information of the business process flow to record views? No problem! Simply add "Stage Category" or other relevant field to Views.

Go into View customization, select Add Column, choose Record Type as "Process Stage," and add "Stage Category" as a column to your View.

Business Process Flows

As we've seen, prep work and research is needed before we can consider planning the design of our Business Process Flows. However, once properly implemented, they can add immense value by helping to establish common processes among your users.

Got any tips to add to the list? Let us know in comments or check out: Two Tips for Business Process Flows!

Happy CRM'ing!

Business Process Flows: Conditional AND Statements in Branching Logic

Branching logic in Business Process Flows are a great component to Dynamics CRM. However, there are a couple of tips and tricks to be aware of that will make using them easier. In today's blog, we will cover conditional AND statements in a branching logic scenario where more than one item in a branch needs to be verified. Let's dive in!

If you have an AND statement in your branching logic, it needs to come first in order for the rest of the Business Process Flow to function properly. The first example below is built so that it will NOT function correctly:

1. In the first branch, it is only verifying one field in the first stage of the Business Process Flow.

2. In the second branch, which is an "else" statement from the first branch, it uses an AND statement to verify two fields in the first stage of the Business Process Flow.

Now, if we look at the Business Process Flow in action and mark both Step 1 (Generic Business Process Field 1) and Step 2 (Generic Business Process Field 2) as Completed, according to the branching logic we built, the next stage should be Stage 2B. However, you can see that it did not change to Stage 2B, but instead went to Stage 2A despite both fields being marked Completed.

Now let's build it so that it will work correctly. First we need to change the order of the conditional statements:

1. Move the AND statement in the first branch.

2. Move the statement only verifying one field to the second branch.

You can see that if we just mark the Step 1 (Generic Business Process Field 1) as Completed, as expected, Stage 2A and Stage 3A appear as the next stages in the Business Process Flow:

Then, when we also mark Step 2 (Generic Business Process Field 2) as Completed, the next stage now correctly changes to Stage 2B.

There you have it! Hopefully this tip will help you build as many functioning Business Process Flows with branching logic as your heart desires! Did you know that PowerObjects offers several educational events and webinars on demand? Sign up for our newsletter so you can stay up to date with the latest and greatest PowerObjects offerings.

Until next time readers, happy CRM'ing!

Stage Gating is Now Honored in MS Dynamics CRM 2015

One exciting new feature that was included in the Spring Update of Microsoft Dynamics CRM 2015 is that stage gating in the business process flow is now honored by the "Qualify" button in the command bar. In previous versions of Microsoft Dynamics CRM, if a required field was in the business process flow, a user could move through the stages without first completing required fields. Clearly this defeats the purpose of having required fields in the first place! In the blog today, we will show you how stage gating honoring works in Dynamics CRM 2015. Let's get started!

The example below is in Microsoft Dynamics CRM 2015 on-premises.

Stage = Qualify, MSDCRM 2015 On-premises version

Stage = Develop

You will notice that the Purchase Process field was never completed, yet the stage is now in Develop. This lead was qualified without the required field being completed.

Per the 2015 Spring Update, users can no longer move through the stages of a business process flow without first completing the required fields in the current stage. The example below is in a Microsoft Dynamics 2015 online version of CRM.

Stage = Qualify, MSDCRM 2015 Online version

Now, users will receive an error message if they try to move to the Develop stage without first completing the required fields in the Qualify stage. Once the required data is entered, users will then be able to move through the business process flow stages.

This new feature allows for more control over movement through business process flow stages by requiring all required fields to be completed before moving to the next stage. This new feature will help enhance reporting accuracy as well as ensure required business processes are followed.

For more helpful information on Microsoft Dynamics CRM, check out our blog weekly, and as always, happy CRM'ing!

Enhanced Business Process Flow Navigation

The Dynamics CRM 2015 spring update brings many great new features to the platform. This blog will discuss the exciting new features for business process flows that will enhance productivity and ease of use in Dynamics CRM. We will specifically look at the new "Set Active" function as part of the enhanced business process flow, and how to easily move to a previous project stage.

In previous versions of Dynamics CRM, it was not possible to move to a previous stage of a business process flow on a different entity. No direct traversing through the UI was possible. Now with the "Set Active" function you can make active any stage in any previous entity of the process. Let's take a look at an example.

Here, we have set up a simple business process flow using the account, order, and activity entities. The stage gates are "Review Store", "Suggest Order", "Plan Visit", "Store Visit", and "Confirm Order". "Review Store" is currently set as the active stage gate in this example.

But let's say we're visiting with our customer and over the course of the meeting we discover that the client has new needs, and the suggested order now needs to be adjusted. No problem! We can select the "Suggest Order" stage gate and click on "Set Active" to re-activate the stage gate on the order entity.

Figure 1: "Suggested Order" is selected.

Now the active stage has been reinstated to "Suggested Order," and the client's new goals can be easily adjusted.

Figure 2: "Suggested Order" is the active stage gate on the order entity

The "Set Active" function is a great new addition to Dynamics CRM 2015. It makes reporting more reliable and makes it easier to manage stage gate processes. Please check back with the PowerObjects blog often for more details and demonstrations on Dynamics CRM.

Happy CRM'ing!

Two Tips for Business Process Flows

Business Process Flows in Dynamics CRM are great tools to help your organization operate smoothly and effectively and can be an integral and important part of a CRM implementation. Depending on your business processes, adding a Business Process Flow to your system can give end users a visualization of where they are at in the sales process and what needs to be completed. Today we’ll be showing you how to add script that will programmatically advance a Business Process Flow stage and we will also show you the steps needed to increase your Business Process Flow Limits. There’s lot of good stuff to get to today, so let’s begin!

Programmatically Advancing Business Process Flows

Navigating through a Business Process Flow is easy but can add extra clicks for users. Advancing a stage in the Business Process Flow is as easy as clicking Next Stage on the right-hand side of the process flow interface. Depending on the type of step, you may need to click it or type information into it. In high volume environments, such as call centers, end users might be clicking the same steps and stages in the Business Process Flow navigation hundreds of times per week. Saving an extra few clicks here and there really add up in these situations.

Please note here that this code can be used with CRM 2015 SP1. There have been some changes for programmatically setting business process flows between CRM 2015 and CRM 2015 SP1. The code below will need to be passed through currentstage, which is available from;

function moveNext(currentStage) {

//Method is used to attempt to move to the next stage in the Business Process Flow

//currentStage is expected to be the current stage name of the record when this method is to be invoked

//console.log("moveNext requested for stage: " +;

var pollingAttemptsRemaining = 10;

var intervalId;

//Cycle through code every 2 seconds for dirty check

intervalId = setInterval(function () {

pollingAttemptsRemaining -= 1;

//console.log("Attempts Remaining: " + pollingAttemptsRemaining);

//Check if the current stage is the same stage that record was in when calling moveNext

//This check is in place after 2015 SP1 due to changes in CRM code handling of moveNext with being called onSave with a dirty form

//Out Of Box moveNext calls an additional save which causes code to be executed twice, this prevents further execution

if ( != currentStage) {



//Check if form is dirty, if it is not and the stage has not changed then attempt to moveNext

if (! && == currentStage) {

console.log("attempting move");;

pollingAttemptsRemaining = 0;



//If number of attempts remaining has passed exit code

if (pollingAttemptsRemaining <= 0) {



}, 200);

This code would be triggered on the onChange of a field. However, there could be a use case to also trigger the onLoad of a form. A common occurrence of this code would be a stage with steps that are also on the form of an entity. Once the user sets the value of the field which is on the form, the step in the Business Process Flow will also change. Once the field is changed and saved, if the trigger is set to onChange on that field, the Business Process Flow will advance to the next stage.

Increasing Business Process Flow Limits

Business Process Flows are highly configurable to fit your organizational needs and are available for out-of-the-box entities as well as your own custom entities. Additionally, an entity can have many business process flows associated with it. Out-of-the-box CRM allows for 10 business process flows per entity, however, this can be an issue if certain entities require more processes than is allowed. Thankfully, a few simple steps are all that is needed to increase your Business Process Flow Limits!

Out-of-the-box CRM allows for only 10 Business Process Flows per entity, however, if your CRM is an on-premises deployment, this number can be modified to better fit your business needs. This modification is NOT supported by Microsoft, however, simply follow the steps given below and there should be no negative repercussions. With that being said, let’s get started!

  1. Access the setting which is stored in your CRM database in the table organization.
  2. The setting you will want is called MaximumActiveBusinessProcessFlowsAllowedPerEntity.
  3. Enter the number of flows you wish to set.


As you can see from the example above, we have now successfully increased the Maximum Business Processes allowed per entity to 15!

That’s all for today’s blog! For more tips and tricks like this one, keep reading our blog each week, and remember to subscribe to our newsletter for CRM updates delivered directly to your inbox.

Happy CRM’ing!


Accessing the Business Process “Name” in Dynamics CRM

In your Microsoft Dynamics CRM musings, you might have come across having multiple business processes that you follow on Opportunities. What do you do if you want to track how many opportunities are following each?


Standard Process flow vs. Streamlined Process flow

The question is how many Opportunities are following the Standard Process and how many are following the Streamlined Process?

The name of the process flow cannot be added to a view within the Opportunity entity, its individual Stage Categories, the entity itself and stage name can be accessed….but not the "NAME" of the Process Flow. Here is the good news! This issue can be solved in a few minutes with a single custom text field and a one line workflow.

Once this field has been populated, standard CRM charting and reporting can be used to provide the information you are looking for.

The workflow is a simple "OnCreate" (Opportunity) and "OnChange" (processed field on the Opportunity) – with one "update" step to update your custom text field that holds the Business Process Name.

To update is simple, look to the image below:

Accessing the Business Process “Name” in Dynamics CRM


We hope you found this enlightening and useful! For even more Dynamics CRM fun, check out our main Dynamics CRM blog page or head over to our Dynamics CRM Education department! Or if you are interested in learning more about business processes we have a good library of knowledge for you!


Happy CRM'ing!

Configuring Dashboards for Business Process Flows

Business process flows help to guide users through a defined set of stages and related steps required to complete a business process. Utilizing process flows can result in improvements in user adoption and provide greater visibility into the sales pipeline. This topic describes how to build process-centric dashboards in Dynamics 365 using out of the box entities.

Each business process flow configured in the Dynamics 365 corresponds with a related process entity that includes information such as active stage, status and start date. As a system customizer, you can edit the sitemap to display these process entities, manage permissions for each process via security roles and build custom views including process data as well as attributes from supporting entities. The custom views can also be used to create visualizations such as charts, sub grids and list views of records.

In this example, the organization is utilizing two types of sales processes that are relevant to opportunity entity. Each of these process entities have been added to the sitemap under the Business Processes section to support a process-centric view for a sales user.

business process flow

The user can select a specific business process from the sitemap and double-click a process record from views to continue progressing the opportunity further.

business process flow

We can configure a Sales Process Dashboard in CRM, leveraging system capabilities together to reduce the number of clicks and improve user experience.

Follow these steps:

1. Create a system dashboard called Sales Process Dashboard from the customizations area.

business process flow

2. Insert a chart component into the dashboard by selecting a business process flow entity, a related view and chart visualization based on the stages of the process.

business process flow

3. Insert a list component into the dashboard by selecting the same business process flow entity and a related custom view that combines information from the process and its supporting entity.

business process flow

4. Save and publish the Sales Process dashboard.

Here is a sample Sales Process Dashboard configured to display information for two sales processes for an organization. As a result, sales users can view process-driven information in a user-friendly manner and identify opportunities that require attention.

business process flow


If you're looking for more Dynamics 365 tips and tricks - subscribe to our blog!

Happy Dynamics 365'ing!

Business Process Flow Designer in Dynamics 365

Business Process Flows (BPF) in Microsoft Dynamics 365 for Sales are a powerful tools to guide users through their organization's processes. In this blog, we will discuss the Business Process Flow designer.

The designer helps system administrators/customizers/super users to easily create a BPF. The designer has a drag and drop UI, which is very helpful when needing to create complex Business Process Flows quickly.

Here is what the designer looks like! It has three main areas: the BPF canvas, Components Panel, and the Action Bar or Menu.

business process flow designer

The designer canvas also has some interesting features: the minimap and fit to canvas options. The minimap gives you the ability to see how complex or branched your overall business process flow is. Also, a dark grey box in the minimap area depicts the current part of the BPF as shown in the canvas.

The Fit to Canvas button is very helpful when you have created a business process which has numerous stages that don't fit into the current canvas view, but you want look at the whole process in detail. Fit to Canvas automatically fits the whole business process flow within the canvas.

business process flow designer

Creating and Editing BPF through the BPF Designer

When you click on a new business process flow, the BPF designer opens with an initial single stage already created. You can define the composition of this stage by adding a data step or a workflow and start creating a process that you need.

To add a data step or a workflow to the required stage, select the stage in the BPF designer canvas. Click on the required composition element block on the right-hand side panel and drag it into the canvas.

business process flow designer

Adding Components to the Business Process Flow

If you want to add more stages or conditions to the business process flow, then click on the required component on the right-hand side panel and drag it to the canvas. You will see "+" sign highlighted in the canvas. Drop the flow component at the required place and update the properties of this component.

business process flow designer

You can also add components using the Actions Bar at the top of Canvas. Click on "+ Add" sign at the top, and select your component that you want to add. You would see a highlighted area in the canvas with "+" sign. Click on the "+" sign where you want to place the required component.

business process flow designer

There are other buttons on the Actions Bar which help you edit or update the Business process flow effortlessly.

You can cut or copy the stage or condition from one place and paste to another in the same business process flow. This is often helpful when you are creating a multiple branched business process flow where some of the stages might be same.

Snapshot saves the whole business process flow in a picture format. This feature is helpful when you want to document your business process flow or share this process outside of Dynamics 365.

business process flow designer

Need more information on business process flows? Check out these blogs:

Happy Dynamics 365'ing!

Understand Business Process Flow Timers

How long is your sales cycle? Is this a question you are commonly asked and need to answer? If you said yes, Dynamics 365 has made it a little easier for you to answer that question now using Business Process Flows.

Business Process Flows have had some significant improvements in Dynamics 365. One feature which has often been requested is the ability to see how long a process has been in a stage as well as how long it took to complete. Dynamics 365 has taken this into consideration and not only displays the timers on the Business Process Flow for the current stage but also the total time spent in the business process flow. In addition, Dynamics 365 also stores the historical data for the total time to complete the business process flow in an entity. This stored data can be used for business intelligence and potential process improvement. Let's take a look:

In the example below, the Opportunity is currently in the Develop stage of the Opportunity Sales Process for 6 days.

In addition, we can see that this opportunity has been in the Opportunity Sales Process for a total of 13 days and 21 hours.

business process flow

Dynamics 365 now creates an entity for the Opportunity Sales Business Process Flow and creates a record for each instance of the business process. In this entity, Dynamics 365 keeps track of data relevant to the business process flow which can be used for business intelligence, among other purposes.

While the time in the Current Stage is not stored, the total time spent for the Sales Process will be stored in the entity with the Business Process Flow name (Opportunity Sales Process, in our example) when the Opportunity Sales Process is completed by the user. We can use an Advanced Find to query this data:

business process flow

Note that Duration is only populated once the Business Process Flow is Completed or Aborted.

business process flow







With this data readily available to us we can now begin to understand more about how long it takes to move through a business process from start to finish.

Comma Delimited String of Process Stage IDs That Represent Visited Stages of the Business Process Flow Instance:

Although, not a timer, another potentially beneficial data point captured in the business process flow instance entity is the path that was taken to get to the closure of the process. This field captures the stages which were visited while the completing the business process. This helps understand if stages were skipped when analyzing the process.

Note: If a user moves back a stage and then moves forward once again, the system does not capture the movement back and forward in this field.







Search our blog for more helpful posts about Business Process Flows here!

Happy Dynamics 365'ing!

Everything You Need to Know About Task Flows

Task flows are an awesome feature available in Microsoft Dynamics 365, and in today's blog, we're giving you the 411 on everything you need to know about them!

What are Task Flows?

Task flows are a user-level approach to managing business processes on the mobile device. In fact, they're actually a subcategory of Business Process flows. Task flows are different from business process flows in that they can be executed by multiple users at the same time on the same record. They also benefit your users by making the underlying CRM data model transparent in the Mobile user interface. User level task flows offer guidance in the mobile UI where the full business process flow form might just be too much information to manage.

Before we get started, you should be aware of three important points:

1. Task flows are currently available for Mobile CRM Mobile app only.

2. Task flows are officially in preview mode (meaning this feature has not yet been completed, but has been made available with limited or restricted functionality with the goal of soliciting feedback from customers).

3. Task flows must first be enabled or turned on and you must accept the license terms before the feature can be used.

Now we can get to the good stuff! First off, let's take a look at how to create a task flow.

How to Create a Task Flow

To create a task flow, you need to access the Processes area under Settings.

1. First, navigate to Settings > Processes > New.

2. For the Category, select Business Process Flow.

3. Then, select the Type Run the process as a task flow (Mobile only).

Task Flows

How to Enable Task Flow Functionality

As we mentioned earlier, task flows must first be turned on or enabled before they can be used. As you can see in the image above, the option to create a task flow is not available since it has not been enabled. To turn on task flows, you need to access the Preview section under System Settings.

1. First, navigate to Settings > Administration.

2. Next, go to System Settings and select the Preview tab.

3. Check that you have read and agreed to the license terms.

4. Select Yes for the Enable Task Flows for Mobile Preview section.

Task Flows

Once enabled, the option to create a task flow will be made available:

1. Navigate to Settings > Processes > New.

2. For the Category, select Business Process Flow.

3. Then, select the Type Run process as a task flow (Mobile only).

Task Flows

That's it! For more tricks and tips, make sure you subscribe to our blog and check out some of PowerObjects' awesome webinars, where we delve into all that's new and exciting with Microsoft Dynamics 365.

Happy Dynamics 365'ing!