CRM Crate

Automatically expand / collapse a BPF in Dynamics 365

We will learn & understand to automatically expand / collapse a BPF in Dynamics 365. Before we start, make sure to subscribe to CRM Crate so that you can stay up to date in field of Dynamics 365.

Automatically expand & collapse a business process flow in Dynamics 365

Why do we need to dynamically collapse and expand a BPF in Dynamics 365?

Business process flows provide a guide for people to get work done. They provide a streamlined user experience that leads people through the processes their organization has defined for interactions that need to be advanced to a conclusion of some kind. This user experience can be tailored so that people with different security roles can have an experience that best suits the work they do.

By default, Microsoft displays the BPF stages in the collapsed view as shown below.

But there can be business scenarios where the users need to automatically change the view of a BPF according to their criteria. We can dynamically change the view (Collapsed, Expanded, Floating) of a BPF using the below given solution.

Using setDisplayState client API for dynamically changing the BPF display states –

We will use the setDisplayState client API for automatically updating the BPF states as given below.


Sets the display state of the business process control.
This API supports three stages namely “Expanded”, “Collapsed” and “Floating”.
Note: – The floating state is not supported in the Web Client.

JavaScript logic for automatically changing the BPF states –

We have triggered the below JavaScript snippet during the “OnChange” event of an entity form.

//CRM Crate - JavaScript Snippet
function CallMethod (executionContext) {

//Reading Attribute Value From The Form.
var formContext = executionContext.getFormContext();

//Reading Value From Input Field
var InputFieldValue = formContext.getAttribute("cc_bpfdisplaystate").getValue();
if(InputFieldValue == 1) // Option-set Value : Expanded

//Using setDisplayState Client API
else if(InputFieldValue == 2) // Option-set Value : Collapsed

//Using setDisplayState Client API
else if(InputFieldValue = 3) // Option-set Value : Floating

//Using setDisplayState Client API

Validate the changes in Dynamics 365 –

We need to verify the implementation in Dynamics 365 form once the above JavaScript code has been configured & deployed as shown below.

Thus, learned to automatically expand & collapse a business process flow in Dynamics 365.

5 2 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
error: CRM Crate Security Engine - Disabled Right Click & Selection!


Well Done,
Welcome to CRM Crate

Stay tuned with us and get all latest updates and learning in Microsoft CRM and related techonologes.