Answered by:
In CRM 2016 online how do I set a Stage in business process flow active on click of a button on ribbon for CRM 0

Question
-
HI,
I need to know what code/ method I can use to set another Stage as Active(which is not completed) which should appear only based on certain condition on click of a button. I used the moveNext function but this doesn't seem to work.
Basically on click of the button:
- I need to set a form field to the Stage name - which is working
- Then I call the movenext function without any parameters - this is not working -- I need to save and refresh the form to see the next Stage appear but the Active stage still remains the old one. If I click on the button again the movenext seems to work and sets this Stage as Active.
Hope this makes sense.
Regards,
Anwesha
- Edited by AnweshaRSharma Sunday, July 31, 2016 3:22 PM
Sunday, July 31, 2016 12:02 PM
Answers
-
Hi Anwesha,
Please try to call the below javascript method on click of you button. You face this problem because of the dirty form.
You can pass the currentStage by getting it from this line of codemoveNext = function (currentStage) { var intervalId; intervalId = setInterval(function () { pollingAttemptsRemaining -= 1; if (Xrm.Page.data.process.getActiveStage().getId() != currentStage) { clearInterval(intervalId); } if (!Xrm.Page.data.entity.getIsDirty() && Xrm.Page.data.process.getActiveStage().getId() == currentStage) { Xrm.Page.data.process.moveNext(onSetActiveStage); pollingAttemptsRemaining = 0; clearInterval(intervalId); } if (pollingAttemptsRemaining <= 0) { clearInterval(intervalId); } }, 200); }
onSetActiveStage = function (returnStatus) {
switch (returnStatus) {
case "success":
break;
case "crossEntity":
alert("crossEntity!");
break;
case "unreachable":
alert("unreachable stage");
break;
case "invalid":
alert("invalid stage");
break;
}
},
var stageID = Xrm.Page.getAttribute("stageid").getValue();
I found this solution from somewhere on web for one of my projects. But don't remember the original link.
Thanks
Sachith
Sachith Chandrasiri
- Edited by Sachith Vidanage Monday, August 1, 2016 5:12 AM forgot to remove project specific words
- Marked as answer by AnweshaRSharma Monday, August 1, 2016 9:49 AM
Monday, August 1, 2016 5:10 AM
All replies
-
Hi Anwesha,
Please try to call the below javascript method on click of you button. You face this problem because of the dirty form.
You can pass the currentStage by getting it from this line of codemoveNext = function (currentStage) { var intervalId; intervalId = setInterval(function () { pollingAttemptsRemaining -= 1; if (Xrm.Page.data.process.getActiveStage().getId() != currentStage) { clearInterval(intervalId); } if (!Xrm.Page.data.entity.getIsDirty() && Xrm.Page.data.process.getActiveStage().getId() == currentStage) { Xrm.Page.data.process.moveNext(onSetActiveStage); pollingAttemptsRemaining = 0; clearInterval(intervalId); } if (pollingAttemptsRemaining <= 0) { clearInterval(intervalId); } }, 200); }
onSetActiveStage = function (returnStatus) {
switch (returnStatus) {
case "success":
break;
case "crossEntity":
alert("crossEntity!");
break;
case "unreachable":
alert("unreachable stage");
break;
case "invalid":
alert("invalid stage");
break;
}
},
var stageID = Xrm.Page.getAttribute("stageid").getValue();
I found this solution from somewhere on web for one of my projects. But don't remember the original link.
Thanks
Sachith
Sachith Chandrasiri
- Edited by Sachith Vidanage Monday, August 1, 2016 5:12 AM forgot to remove project specific words
- Marked as answer by AnweshaRSharma Monday, August 1, 2016 9:49 AM
Monday, August 1, 2016 5:10 AM -
Thank you so much Sachith. worked like magic for me. :DMonday, August 1, 2016 9:49 AM