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 / executionContext.getEv...
Power Apps
Answered

executionContext.getEventArgs(...).preventDefault is not a function

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi All, 

 

I'm trying to disable stage transition on a BPF for all users. 

 

Following the suggestion at https://learn.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/events/onprestagechange I'm registering the below function on form load:

 

 

 

onLoad = (executionContext) => {
 //Attach pre-stage change handler
 formContext.data.process.addOnPreStageChange(() => { this.stageChangeWarning(executionContext) });
 };

 

 

 

The stageChangeWarning function looks like this: 

 

 

stageChangeWarning = (executionContext) => {
 //Compose notification obj
 const notification = {
 type: 2,
 level: 2,
 message: "This is automated process. Moving between stages from there is not allowed.",
 showCloseButton: true
 }
 //Prevent stage change.
 executionContext.getEventArgs().preventDefault();

 //Trigger notification.
 Xrm.App.addGlobalNotification(notification).then(function onSuccess(result) {
 //Remove noticication message after 10 seconds
 window.setTimeout(function () {
 Xrm.App.clearGlobalNotification(result);
 }, 10000);
 })

 };

 

 

However when I test it I receive "executionContext.getEventArgs(...).preventDefault is not a function" error & the form is saved as expected. 

 

Do you happen to know what I'm doing wrong here?

I have the same question (0)
  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Parameters should be passed in the callback function.

    vxiaochenmsft_0-1683166630033.png

    vxiaochenmsft_1-1683166648965.png

     

    Hope it helps.

     

    Best Regards,

    Wearsky

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Indeed! This was it! Wearsky, thank you very much! 

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 531 Most Valuable Professional

#2
Haque Profile Picture

Haque 261

#3
Kalathiya Profile Picture

Kalathiya 221 Super User 2026 Season 1

Last 30 days Overall leaderboard