Hi People,
Through This below stated code, I am using to change the optionset value on change of business process flow. But after clicking on next stage, stage is changing fine and even field is also updated but change in field is under unsaved changes, Need quick help on this,
how can I save the change that I did on addOnStageChange.
function ChangeStage()
{
Xrm.Page.data.process.addOnStageChange(StateChanged);
}
function StateChanged() {
var selectedStage = Xrm.Page.data.process.getSelectedStage().getName();
var suspect = 100000000;
var prospect = 100000001;
var analysis = 100000002;
// Set optionset value
if (selectedStage == "Suspect") {
Xrm.Page.getAttribute("shell_pipelinephase").setValue(suspect);
}
elseif (selectedStage == "Prospect") {
Xrm.Page.getAttribute("shell_pipelinephase").setValue(prospect);
}
elseif (selectedStage == "Analysis") {
Xrm.Page.getAttribute("shell_pipelinephase").setValue(analysis);
}
Xrm.Page.data.entity.save();
}