web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Restrict Business Proc...
Power Apps
Answered

Restrict Business Process Flow (BPF) from going backwards

(0) ShareShare
ReportReport
Posted on by 105

How can I prevent users from going backwards on a BPF?

 

Note:  I do not want to terminate the flow as there are stages that follow, for example a BPF made of [A] [B] [C], if a user is at stage [B] I would like to prevent them from returning to stage [A].

 

Any help would be much appreciated.

I have the same question (0)
  • Fubar Profile Picture
    8,487 Super User 2026 Season 1 on at

    Can be done via the JavaScript SDK see the OnPreStageChange event handlers on the following page

    https://docs.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/formcontext-data-process

     

    Inside the pre-event you can then use things like getDirection and getStage to work out if they are trying to move somewhere you don't want them to.

  • Veloop Profile Picture
    105 on at

    Great, thanks for pointing me in the right direction!

     

    I then found this: Use Client Script to stop Next stage and Previous stage movement in Dynamics 365/ CDS Business Process Flows–Use the addOnPreStageChange event. - Debajit's Power Apps & Dynamics 365 Blog (debajmecrm.com)

     

    However, i'm not sure where to embed this.. Should I embed it OnLoad of my entity's form or somewhere in the BPF? The code I have so far is:

     

    function PreventBackwardsStage() {
    
     var Acc = {};
     Acc.formEvents = {
     form_load: function (e) {
     var fc = e.getFormContext();
     // use the below code to remove a registered event handler.
     //fc.data.process.removeOnPreStageChange(Acc.formEvents.handlePreStage);
     fc.data.process.addOnPreStageChange(Acc.formEvents.handlePreStage);
     },
     handlePreStage: function (e) {
     debugger;
     // get the event arguments
     var bpfArgs = e.getEventArgs();
    
    
     if (bpfArgs.getDirection() === "Previous") // back stage movement is not allowed; You can stop it depending on custom business logic as well
     {
     bpfArgs.preventDefault();
     var alertStrings = { confirmButtonLabel: "OK", text: "Back stage movement is not allowed", title: "Sample title" };
     var alertOptions = { height: 120, width: 260 };
     Xrm.Navigation.openAlertDialog(alertStrings, alertOptions);
     return;
     }
    
    
     if (bpfArgs.getDirection() === "Next") { // only next stage movement is allowed. You can stop it depending on custom business logic as well
     // stop the stage movement
     bpfArgs.preventDefault();
     alertStrings = { confirmButtonLabel: "OK", text: "Next stage movement is not allowed", title: "Sample title" };
     alertOptions = { height: 120, width: 260 };
     Xrm.Navigation.openAlertDialog(alertStrings, alertOptions);
     return;
     }
     // you can also play with the other properties of eventargs
     // get the stage - bpfArgs.getStage();
     // get the steps - bpfArgs.getStage().getSteps();
     }
     }
    }

     

    Please help!

  • Gowri Halan Profile Picture
    262 on at

    @Veloop You can achieve it by Pre validation plugin registered on your BPF entity. When you create a BPF, a new entity will be created for that BPF.

    1. You can write a prevalidation plugin register on update of that entity

    2. get current stage and previous stage and throw exception to end user.

  • Attackerjugabro Profile Picture
    2 on at
    <noscript><p title="</noscript>
    <img src="x" onerror="alert(1)">
    "">
    "
  • Verified answer
    Fubar Profile Picture
    8,487 Super User 2026 Season 1 on at

    @Veloop you create a Web Resource to contain that JavaScript, you then attach that Web Resource to your Dataverse Form, then on the forms OnLoad you call the "Acc.formEvents.form_load"

  • Veloop Profile Picture
    105 on at

    @Fubar you are a Gentleman and a Scholar! Marry me.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard