Looking for PowerObjects? Don’t worry, you’re in the right place! We’ve been part of HCL for several years, and we’ve now taken the final step in our acquisition journey: moving our website to the HCL domain. Nothing else is changing – we are still fanatically focused on Microsoft Business Applications!

HCLTech Microsoft Business Applications Practice Blog

for Dynamics 365, Power Platform and the rest of the Microsoft technology stack

Collapsing Business Process Flows in Dynamics CRM 2013/2015

Post Author: HCLTech |

Are you using an out-of-the-box Business Process Flow in Microsoft Dynamics CRM 2013 or 2015, but want to have it collapsed by default? Then today we have the answer for you! Business Process Flows are tools that help guide users through business processes in CRM. However, if your organization doesn't wish to utilize the built-in Business Process Flow, simple JavaScript is all that is needed to collapse them.

In this example, we will show the steps for collapsing the Business Process Flow on the Opportunity record. The following JavaScript must be placed in the OnLoad event on the Opportunity form:

function collapseOpporBusinessProcess(){setTimeout(collapseOpporBusinessProcessDelay,300)}

function collapseOpporBusinessProcessDelay(){Xrm.Page.ui.process!=null&&Xrm.Page.ui.process.setDisplayState("collapsed")}

Here are the step-by-step instructions for deploying custom JavaScript in Dynamics CRM. Please note before getting started that you will need the appropriate permissions and the System Administrator or System Customizer role may be required. .

Step 1:    Launch Form Editor for the Opportunity record, then click on Form Properties from the ribbon.

Collapse Business Process Flows

Step 2:    Add a New Library by clicking Add in the Form Properties section.

Collapse Business Process Flows

Step 3: When a dialog box is presented, on the bottom left, select New to create a new web resource.

Collapse Business Process Flows

Step 4: Provide an appropriate Name and Display Name. From the Type selection, choose Script (Jscript), then click Text Editor.

Collapse Business Process Flows

Step 5:    Paste in the following code.

function collapseOpporBusinessProcess(){setTimeout(collapseOpporBusinessProcessDelay,300)}

function collapseOpporBusinessProcessDelay(){Xrm.Page.ui.process!=null&&Xrm.Page.ui.process.setDisplayState("collapsed")}

Collapse Business Process Flows

Click OK. Save, Publish and Close the newly created Web Resource. CRM returns you to the Web Resource Look Up dialog window.

Step 6:    Click Add to add the newly created Web Resource to the Form Library.

Note: if the new web resource is not already selected you may search for it again as shown here.


Step 7:     Now scroll down to the Event Handler section on the Form Properties window. Ensure the Control is set to Form and Event is set to OnLoad, then click Add.

Collapsing Business Process Flows

Step 8:    On the Handler Properties window, paste in the Function Name, collapseOpporBusinessProcess, and click OK.

Collapsing Business Process Flows

Step 9: On the Form Properties window, click OK, then on the Opportunity Form, click Save and Publish.

Collapsing Business Process Flows

Now you are all set! You will now see that the Business Process Flow will be collapsed. You may see if for a brief period immediately following the above steps due to timeout settings in the code. This is required in order to allow the entire form to load (including sub-girds and other elements). The out-of-the-box expand/collapse functionality will still remain in place.

Collapsing Business Process Flows

That's all for today, folks. For additional tips and tricks, visit our blog weekly. You can also find more information regarding Business Process Flows in CRM 2015 here. And as always, if you need additional assistance with Dynamics CRM, don't hesitate to reach out to us here at PowerObjects.

Happy CRM'ing!


By Joe D365
Joe D365 is a Microsoft Dynamics 365 superhero who runs on pure Dynamics adrenaline. As the face of PowerObjects, Joe D365’s mission is to reveal innovative ways to use Dynamics 365 and bring the application to more businesses and organizations around the world.

5 comments on “Collapsing Business Process Flows in Dynamics CRM 2013/2015”

  1. A really insightful post.....thanks for the share....for more info about the latest CRM software visit: Cloudnex.com.au/products/crm/.

  2. Hello,

    When I try to implement this, I get the following error onload:

    There was an error with this field's customized event.

    Field: window
    Event: onload

    Error:'collapseOpporBusinessProcess' is undefined

    Any ideas on how to make this work properly?

    1. It's likely due to an issue with the quotation marks when copying JS from the website. Just remove and add them back and you should be good to go.

  3. For me the error was caused by the ". Replace them and it should work.

    Here is what was in post:

    function collapseOpporBusinessProcess(){setTimeout(collapseOpporBusinessProcessDelay,300)}

    function collapseOpporBusinessProcessDelay(){Xrm.Page.ui.process!=null&&Xrm.Page.ui.process.setDisplayState(“collapsed”)}

    Here is what worked for me:

    function collapseOpporBusinessProcessDelay(){Xrm.Page.ui.process.setDisplayState("collapsed")}
    function collapseOpporBusinessProcessDelay(){Xrm.Page.ui.process.setDisplayState("collapsed")}

    Hope that helps.

PowerObjects Recommends