CRM – Business Process flows and JavaScript

Microsoft describe the logic for business process flows here. As I’ve been working with business process flows recently I thought I would do a quick post explaining how to access all of the parts of a business process flow.

You use “Xrm.Page.ui.process” to access the business process flows. Then “getActiveProcess” returns an object containing the current active process.

Within this object a collections exists of the stages within the process. Then within that another collection exists containing details of each of the steps in the stage.

I’ve given an example below of how to access all of this information. Plus shown how to expand / collapse the business process flow control. And to also hide it.

Happy coding!

// *** Collapsed or Expanded?
// ** Now you see it
Xrm.Page.ui.process.setVisible(true); // ** Or false

// **getActiveProcess
var activeProcess =;

alert("ID of the process: " + activeProcess.getId());
alert("Name of the process: " + activeProcess.getName());

// ** getStages
var StageCollection = activeProcess.getStages();

StageCollection.forEach(function (stage, n) {
  //stage index
  var stageIndex = n;
  alert("Stage Index: " + stageIndex);

  //stage category number
  var stageCategory = stage.getCategory().getValue();
  alert("Stage Category: " + stageCategory);

  //stage id
  var stageId = stage.getId();
  alert("Stage Id:" + stageId);

  //stage entity name
  var stageEntityName = stage.getEntityName();
  alert("Stage Entity ID: " + stageEntityName);

  //stage name
  var stageName = stage.getName();
  alert("Stage Name :" + stageName);

  //stage status
  var stageStatus = stage.getStatus();
  alert("Stage Status: " + stageStatus);

  //steps collections
  var stepsCollection = stage.getSteps();

  //Number of steps
  var stepsLength = stepsCollection.getLength();
  alert("Steps Length: " + stepsLength);

  stepsCollection.forEach(function (step, i) {

    //step name
    var stepName = step.getName();
    alert("stepName:" + stepName);

    //step attribute
    var stepAttribute = step.getAttribute();
    alert("stepAttribute:" + stepAttribute);

    //step is required
    var stepIsRequired = step.isRequired();
    alert("stepIsRequired:" + stepIsRequired);


// ** Now you don't see it!
Xrm.Page.ui.process.setVisible(false); // ** Or true

2 thoughts on “CRM – Business Process flows and JavaScript

  1. Pingback: Business Process Flows – Javascript (part 2) | Microsoft Dynamics CRM and Unified Service Desk

  2. Pingback: Business Process Flows – Javascript (part 2) - Microsoft Dynamics CRM Community

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s