Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Couldn't move to next stage in Business Process Flow !! in Dynamics 365

Posted on by Microsoft Employee

Requirement is to move back to previous stage when condition fails ... 

I used following Javascript to achieve it 

Xrm.Page.data.process.addOnStageChange(onStageChange);
function onStageChange() {
alert("Contact Number should not be Empty - Can't move to next stage");
Xrm.Page.data.process.movePrevious(moveResult);
flag == 1;
}

The problem is after moving to previous stage. It does not allow me to move to Next stage though the conditon gets passed. Your help is much appreciated !

Thanks,

Vignesh Mohan

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Couldn't move to next stage in Business Process Flow !! in Dynamics 365

    Adam,

    Its only part of the code, we have validation where Appointment activity should be created before moving next stage. In such cases we preferred script. Another problem is we have more 250 validation to be checked. I hope it can't be done in OOB feature.

    Thanks!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Couldn't move to next stage in Business Process Flow !! in Dynamics 365

    I'm curious as to why you don't just make those steps (fields) in the business process "required" - this OOB feature is designed to prevent users from moving to the next stage unless and until the requiredc steps are filled in. This is not the same as a field being business required, which prevents the record being saved if the field is null; a required step only prevents moving stage of the process forward.

    If your conditions were more complex such as "must provide contact number or email address", then things might be different (but there are other ways to address that too).

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Couldn't move to next stage in Business Process Flow !! in Dynamics 365

    ok the part that gave include flag == 1 instead of flag = 1

    can you correct that and retest?

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    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() {
    }

    }

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Couldn't move to next stage in Business Process Flow !! in Dynamics 365

    Hi,

    Either you didn't paste all the code or as I see it now, you are not checking if your condition is met before moving back, i.e.

    function onStageChange() {

    if(XXX == null){

    alert("Contact Number should not be Empty - Can't move to next stage");

    Xrm.Page.data.process.movePrevious(moveResult);

    flag == 1;

    }

    }

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