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 / Discard Changes after ...
Power Apps
Answered

Discard Changes after Form Change Javascript

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,

 

I'm using a Javascript OnLoad to navigate to different forms based on the conditions. The whole logic and navigate to a different form works without issue, but now as there are some default values in the form, before navigate it asks to Save or Discard changes.

 

Is it possible to navigate to a different form, discard the changes automatically and not show the pop up?

I'm using this code to change the form, where newFormLabel is Id of new form.

 

formContext.ui.formSelector.items.get(newFormLabel).navigate();

 

 

 

Thank you

Tomas

Categories:
  • Verified answer
    v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

     

    Before navigate to another form, you can clear the default value.

     

    For example:

    function Test3(executionContext) {
     var formContext = executionContext.getFormContext(); // get formContext	
     formContext.getAttribute("cr25b_name").setValue(null);
     formContext.ui.formSelector.items.get("...").navigate();
    
    }

     

    Best Regards,

    Wearsky

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Just a small update how we solved it finally. JS is dismissing the pop up before it appears.

     function setSubmitModeForAttributes(){
     var attributes = formContext.data.entity.attributes.get();
     for (var i in attributes)
     { 
     attributes[i].setSubmitMode("never"); 
     }
     }

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 225

#3
M Bilal Khan Profile Picture

M Bilal Khan 192

Last 30 days Overall leaderboard