i am trying to change BPF whole process based on field value it is working for only one value(NO) for others it is not changing here is my code pls suggest. for selecting No it is changing for Yes & Waiting it is not changing
function onload() {
// If not new Case form
// if (Xrm.Page.ui.getFormType() != 1) {
// Read Origin Option text
var origin = Xrm.Page.data.entity.attributes.get("new_aprroving");
// if (origin && origin.getText()) {
var caseOrigin = origin.getText();
alert(caseOrigin);
// Get Business process flow id
var processFlow1Id = "7B02E72B-44F0-49D7-975D-6C0B20B2DFDE";
var processFlow2Id = "4BF02651-9A0A-48CC-9AAF-2B1E07A3DFC0";
var processFlow3Id = "46144F08-5B03-442B-A9C5-E3AFBB957EF2";
// Get Current Active Process Id
var activeProcess = Xrm.Page.data.process.getActiveProcess();
var currProcessId = activeProcess.getId();
if (caseOrigin.toLowerCase() == "yes") {
alert(currProcessId);
// Change the process only if current Active Process not the Target one
if (currProcessId.toLowerCase() != processFlow1Id.toLowerCase()) {
alert("yes1");
// Switch to the “Process Flow 1”
Xrm.Page.data.process.setActiveProcess(processFlow1Id, myCallBack);
}
} else if (caseOrigin.toLowerCase() == "no") {
// Change the process only if current Active Process not the Target one
if (currProcessId.toLowerCase() != processFlow2Id.toLowerCase()) {
// Switch to the “Process Flow 2”
Xrm.Page.data.process.setActiveProcess(processFlow2Id, myCallBack);
}
else if (caseOrigin.toLowerCase() == "waiting") {
// Change the process only if current Active Process not the Target one
if (currProcessId.toLowerCase() != processFlow3Id.toLowerCase()) {
// Switch to the “Process Flow 3”
Xrm.Page.data.process.setActiveProcess(processFlow3Id, myCallBack);
}
}
// Call back function post Process flow switch
function myCallBack(response) {
if (response == "success") {
alert("BPF changed !!!");
// Save the form
Xrm.Page.data.entity.save();
}
else {
alert("Error changing BPF!!!");
}
}
}
}
*This post is locked for comments