Archive

Posts Tagged ‘Stage Name’

Code Snippet | JScript | Capture BPF Stage Parameters

Below is code snippet to capture the BPF stage parameters up on the ‘Stage’ change using jscript.

function onload(executionContext) {
    var formContext = executionContext.getFormContext();
    // Register event handler on Process Stage Change
    formContext.data.process.addOnStageChange(onStageChange);
}

function onStageChange(executionContext) {
    var formContext = executionContext.getFormContext();
    var stage = formContext.data.process.getSelectedStage();
    // Get Stage Name
    var currStageName = stage.getName();
    // Show Stage Name
    Xrm.Navigation.openAlertDialog({ text: "Current StageName - " + currStageName });

    // Get Stage ID
    var stageID = stage.getID();
    // Get Entity Name
    var stageEntityName = stage.getEntityName();
    // Get Stage Status
    var stageStatus = stage.getStatus();
}
  • Save this script as web resource and register both the ‘onload’ and ‘onStageChane’ functions on form’s onload event.
  • Below is the example of script on Opportunity form.

🙂

Categories: PowerApps Tags: , ,