I used the same code, but getting an error after whole code gets executed. please have a look at my code and let me know if you find any error.
function setStatusReason(executionContext) {
debugger;
var formContext = executionContext.getFormContext();
if (formContext != "" && formContext != undefined && formContext != null) {
formContext.data.process.addOnStageChange(getStage(formContext)); // Trigger the function when move to next stage.
}
}
function getStage(formContext) {
debugger;
var entityName = formContext.data.entity.getEntityName();
var activeStage = formContext.data.process.getActiveStage();
var stagename = activeStage.getName();
switch (stagename) {
case "New":
if (entityName == "nt_interstatetransfers") {
formContext.getAttribute("statuscode").setValue(206400005);
} else {
formContext.getAttribute("statuscode").setValue(206400004);
}
break;
case "Review Required":
if (entityName == "nt_interstatetransfers") {
formContext.getAttribute("statuscode").setValue(206400004);
} else {
formContext.getAttribute("statuscode").setValue(1);
}
break;
case "HR Approval":
if (entityName == "nt_employee") {
formContext.getAttribute("statuscode").setValue(206400006);
} else {
formContext.getAttribute("statuscode").setValue(206400001);
}
break;
case "Payroll Review":
formContext.getAttribute("statuscode").setValue(206400002);
break;
case "Payroll Approval":
formContext.getAttribute("statuscode").setValue(206400003);
break;
default:
formContext.getAttribute("statuscode").setValue(1);
}
}
any help here is much appreciated.
Thanks,
Hardik Chauhan