RE: Couldn't move to next stage in Business Process Flow !! in Dynamics 365
code for your reference
if (Xrm.Page.getAttribute("stepname").getValue() == ("3-Propose")) {
Xrm.Page.ui.tabs.get("suspect").setVisible(true);
Xrm.Page.ui.tabs.get("prospect").setVisible(false);
Xrm.Page.ui.tabs.get("applicant").setVisible(false);
}
else if (Xrm.Page.getAttribute("stepname").getValue() == "2-Develop") {
var flag = 0;
Xrm.Page.ui.tabs.get("suspect").setVisible(false);
Xrm.Page.ui.tabs.get("prospect").setVisible(true);
Xrm.Page.ui.tabs.get("applicant").setVisible(false);
if (Xrm.Page.getAttribute("new_contactnumber").getValue() == null) {
flag = 4;
}
if (flag == 4) {
alert("Contact Number should not be Empty - Can't move to next stage");
Xrm.Page.data.process.addOnStageChange(onStageChange);
flag == 1
}
else {
if (Xrm.Page.getAttribute("new_needtosendquote").getValue() == true) {
// Check for Quote Approval Record
var _res = CheckQuoteApproval('3-Propose');
if (_res == true) {
// Check for Appointment record - First Level Meeting
var _resul = CheckAppointmentSuspect();
if (_resul == true) {
}
else {
alert("Need to create and capture first level meeting - Can't move to next stage");
Xrm.Page.data.process.addOnStageChange(onStageChange);
flag = 1;
}
}
else {
alert("Sending and getting Approval for Quote / Plan is Mandatory in Suspect Stage - Can't move to next stage");
Xrm.Page.data.process.addOnStageChange(onStageChange);
flag = 1;
}
}
else {
var _resul = CheckAppointmentSuspect();
if (_resul == true) {
}
else {
alert("First level meeting need to captured in Appointment & Appointment should be Completed - Can't move to next stage");
Xrm.Page.data.process.addOnStageChange(onStageChange);
flag = 1;
}
}
}
function onStageChange() {
Xrm.Page.data.process.movePrevious(moveResult);
function moveResult() {
}
}