I am tracking the stages of Business process flow and setting the field values,
convert this to Form context format;
function formonload() {
Xrm.Page.data.process.addOnStageChange(getStage); // Trigger the function when move to next stage.
getStage();
}
function getStage() {
var activeStage = Xrm.Page.data.process.getActiveStage();
var stagename = activeStage.getName();
switch (stagename) {
case "Stage1": // Stage of business process flow
Xrm.Page.getAttribute("field_1").setValue(1);
break;
case "Stage2": //Stage of business process flow
Xrm.Page.getAttribute("field_1").setValue(2);
break;
default:
}
}