Skip to main content
Post a question

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id : XsBBLzC3toWnwVD22wdOPH

JavaScript, add code on business process flow change and select

Neil Parkhurst Profile Picture Neil Parkhurst 10,727 User Group Leader

Recently I needed to add code when stages in my business process flow were selected or changed. This is easy to do.

Simply register the functions you wish to be called as users change or select stages in your onload event.

Sample code is shown below;

function OnLoad() {
  // *** Whenever the stage changes trigger an onchange function
  Xrm.Page.data.process.addOnStageChange(stageOnChange);
  // To remove the function if required ….. Xrm.Page.data.process.removeOnStageChange(stageOnChange);

  // *** Whenever a stage is selected trigger a function
  Xrm.Page.data.process.addOnStageSelected(stageSelected);
  // To remove the function is required …. Xrm.Page.data.process.removeOnStageSelected(stageSelected);
}

function stageOnChange() {
  stage = Xrm.Page.data.process.getActiveStage();
  alert("The stage has changed to " + stage.getName());
}

function stageSelected() {
  stage = Xrm.Page.data.process.getSelectedStage();
  alert("Selected stage is " + stage.getName());
}

This is a short but hopefully useful post.
J


Filed under: CRM2016 - JavaScript, Uncategorized Tagged: crm2016, Javascript, Microsoft Dynamics CRM

This was originally posted here.

Comments

*This post is locked for comments