Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Prevent user to go to next stage

Posted on by 1,558

Hello All,

I am stuck in a senario can anyone help.
I have a business process flow which having three option sets field. So,if these three field will be set YES then user only allow to go next stage else need to show error message. "please set field as YES"
I am using below code but not working as expected.

function OnPageLoad() {
Xrm.Page.data.process.addOnStageChange(stageChangeEvent1);
}

function stageChangeEvent1(ExecutionContextObj) {
debugger;
var f = "";
var stageName = Xrm.Page.data.process.getActiveStage().getName();
if (ExecutionContextObj.getEventArgs().getDirection() === "Next") //"previous" for previous stage{
if (Xrm.Page.getAttribute("stageid").getValue() == "6b9ce798-221a-4260-90b2-2a95ed51a5bc" && Xrm.Page.getAttribute("new_flag").getValue() == true) {
if (Xrm.Page.getAttribute("new_cqflage").getValue() == true) {
f += "CQ";
}
if (Xrm.Page.getAttribute("new_pqflage").getValue() == true) {
f += "PQ";
}
if (Xrm.Page.getAttribute("new_rtflage").getValue() == true) {
f += "RT";
}
if (f != null && f != "") {
Xrm.Page.ui.setFormNotification(f + "not found", 'ERROR', 'alert3');
Xrm.Page.data.process.moveNext(function (result) {
return false;
});
}
else {
Xrm.Page.ui.clearFormNotification('alert3');
}

}
}

*This post is locked for comments

  • Verified answer
    Iswarya Profile Picture
    Iswarya 1,345 on at
    RE: Prevent user to go to next stage

    Hi,

    Xrm.Page.data.process.addOnStageChange(onStageChange);
    function onStageChange() {
    alert("please set field as YES");
    Xrm.Page.data.process.movePrevious(moveResult);
    flag == 1;
    }

    (Here I am having optionset field in Qualify stage i try to move Qualify to Develop stage without making the field yes, this script not allow to go next stage)

    refer this : community.dynamics.com/.../249887

  • Tin Profile Picture
    Tin 1,558 on at
    RE: Prevent user to go to next stage

    Hi, I want to restrict users to move on next stage when few two options sets fields will be YES.

  • Jeevarajan Kumar Profile Picture
    Jeevarajan Kumar 747 Most Valuable Professional on at
    RE: Prevent user to go to next stage

    Hi Tin,

    May I know what is the exact issue you are facing?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans