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 / Help using Variable to...
Power Apps
Unanswered

Help using Variable to change button status

(0) ShareShare
ReportReport
Posted on by 200

I have a screen where i have 30 sliders that are used to enter various ratings.  what i am trying to do is have my submit button grey unless one of the sliders changes.  I've set a boolean variable called VarChanges with a default value of false.  with the OnChange field for my slider i have UpdateContext({VarChanges: true}).  For my button, in the onSelect box i have UpdateContext({VarChanges: false}) & SubmitForm(Form1_1) .

 

i have a label that shows me the value of VarChanges and when it updates correctly to true when i change the slider.   However, when i click my button, the label first changes to false and then back to true.  If i click a second time without making any VarChanges becomes false.

 

Any idea why this variable is getting reset to true?  is there a better way than this to control the color of a button when changes have occured but are not yet submitted?

Categories:
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Frac 

    Set your button's display mode to If(varchanges, DisplayMode.Edit, DisplayMode.Disabled) and set the button's OnSelect to SubmitForm(Form1_1).  Set the OnSuccess property of the form to UpdateContext({varchanges:false}).  to avoid unexpected results, do not chain commands with SubmitForm().  Put them in the OnSuccess property of the form. You do not want them to execute if the submission fails.  

  • Frac Profile Picture
    200 on at

    I made the changes you recommended but my app is still doing the same thing, where the first submit updates VarChanges twice, from true to false to true.  i if click submit a second time without adjusting anything it updates to false

    Capture2.PNG
    Capture.PNG
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Frac 

    Instead of OnChange, use OnCheck and OnUncheck to set your variable.

  • Frac Profile Picture
    200 on at

    @Drrickryp I'm using a slider as my input control,  it only has onchange and onselect

    Capture3.PNG

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 250

#3
Mohsin Ali Profile Picture

Mohsin Ali 225

Last 30 days Overall leaderboard