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 / Form Reset Triggering ...
Power Apps
Answered

Form Reset Triggering OnChange for ComboBoxes and Date Pickers

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello! Somewhat new to Powerapps here!

 

The app I'm building allows the user to view a SharePoint data form in edit mode on its own screen, make changes, and either apply or cancel those changes. Every field in the form is set to change a "boolean" variable, rwUpdates, to true when a change is made, disabling the buttons that would navigate away from the screen on click until the user submits the form changes or cancels the changes. Cancelling will reset the form to its initial values and set rwUpdates to false, thus re-enabling the navigation buttons. Applying the changes will submit the form.

 

But here's the issue: reseting the form causes Combo Boxes and Date Pickers to re-trigger the OnChange event, causing a loop. I currently have an awkward solution where pressing cancel sets another variable to true when the form is being reset,and the OnChange event won't change rwUpdates to true if that other one is true. Then there's a timer involved which will change that second variable back to false once the form has finished reseting (if I can only get rid of this timer bit, I'd be happy).

 

Is there a reason why Combo Boxes and Date Pickers seem much more delicate when it comes to OnChange events than, say, text inputs? And is there a neater solution to this predicament I just haven't thought of? Combo Boxes especially just seem to trigger the event at every little thing, even changing the item for the form!

 

Thanks for your time!

Categories:
  • v-micsh-msft Profile Picture
    Microsoft Employee on at

    For the OnChange property of ComboBox control, would it work by adding an Form.Mode checking first?

     

    Regards,

    Michael

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hm. Not quite sure if that'll do it. The form mode is always in edit, never view or new. Unless there's a "reset mode" it will either always trigger or never trigger, similar to before.

     

    My new-and-slightly-improved method is saving all the values of Date Pickers and Combo Boxes into variables initially and, whenever a field is changed, comparing the "old" value with the new. If they're the same, don't fire the event, otherwise, do. So far it's working, but I've got to put it through more tests to be sure.

     

    It's also somewhat hideous, but anything's better than a timer.

  • Verified answer
    Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    If you can move the buttons that allow the user to navigate away from the screen into a data card on the form then you could take advantage of the form control property called "UnSaved". This property can only be access from the form. It returns false if nothing has changed and true if something has changed. If you reset the form it returns to false. If you can use this feature then all the OnChange code wouldn't be needed.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I didn't even know about that property! That's nearly exactly what I was looking for.

     

    It seems like you don't even need to have the button within the form for it to work, so this works in that department. My only remaining issue is that if the user were to "deselect" the selected Combo Box option (clicking it again in the drop down and clearing the field), it doesn't mark the form as unsaved. Is there a way to maybe prevent re-clicking the selected option to remove it and force the user to use the x instead? Or maybe some way of seeing that that specific event happened so I can manually trigger the event...

     

    Thank you!

  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    @Anonymous,

     

    I think you just found a bug. I have two combo boxes on my test app and one was derived from a SharePoint Choice colum single select and the other is a multi-select SharePoint Choice colum. The multi select works as you would want which is if an item is deselected the UnSave property changes to True. If I do the same thing with the single select field the UnSave property does not change to True.

     

    @v-micsh-msft,

    Is this a bug?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    If it is, I'm quite interested in a solution, since I can't quite think of a way around it!

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 350 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 318

#3
Mohsin Ali Profile Picture

Mohsin Ali 220

Last 30 days Overall leaderboard