Forum Discussion
PowerApps: Using Buttons to Update Existing Records
Hello,
I am trying to use buttons to populate my "ApprovalDecision" column instead of having the user type in "yes" or "no". I am new to PowerApps so I am unsure how to do this. This screenshot shows where I am currently at, and I have not been able to figure it out. Any help or suggestions are appreciated, thanks!
Hi zlasek
you already have a form "Form1" with the "ApprovalDecisionDatacard1"
Select that card and select "Unlock to change properties" on the right sideThe create a new Button "Approve" and set it's OnSelect Property to
Set(varApprovalResult,"Yes")
and another Button "Reject" and set it's OnSelect Property to
Set(varApprovalResult,"No")
Then select the ApprovalDecisionDatacard1 and set it's Default Property to "varApprovalResult"and the Property "Visible" to false
This should be enough to fix your usecase.
But you should also initialize the "varApprovalResult" variable in the "On Visible" property of your screen "Details" likeSet(varApprovalResult,BrowseGallery1.Selected.ApprovalDecision)
and enable/disable your "Approve"/"Deny" buttons by using this formula in their "DisplayMode " properties
If(varApprovalResult="Yes",DisplayMode.Edit,DisplayMode.Disabled)
Best Regards,
Sven
- SvenSieverdingBronze Contributor
Hi zlasek
you already have a form "Form1" with the "ApprovalDecisionDatacard1"
Select that card and select "Unlock to change properties" on the right sideThe create a new Button "Approve" and set it's OnSelect Property to
Set(varApprovalResult,"Yes")
and another Button "Reject" and set it's OnSelect Property to
Set(varApprovalResult,"No")
Then select the ApprovalDecisionDatacard1 and set it's Default Property to "varApprovalResult"and the Property "Visible" to false
This should be enough to fix your usecase.
But you should also initialize the "varApprovalResult" variable in the "On Visible" property of your screen "Details" likeSet(varApprovalResult,BrowseGallery1.Selected.ApprovalDecision)
and enable/disable your "Approve"/"Deny" buttons by using this formula in their "DisplayMode " properties
If(varApprovalResult="Yes",DisplayMode.Edit,DisplayMode.Disabled)
Best Regards,
Sven- zlasekCopper ContributorThis worked perfectly, thank you! Now is there a way to add formatting to the button once clicked to show that it was selected? For example, if a user selects "Approve" the button turns a different color?
- SvenSieverdingBronze Contributor
Sure, this works like disableing the buton. Set it's "Fill" property to a different color depending on the variable varApprovalResult like this (Sets the button's color to grey, if approved and to green otherwise)
If(varApprovalResult="Yes",Color.Grey,Color.Green)
Or more with more colorsIf(varApprovalResult="Yes",Color.Grey,If(varApprovalResult="No",Color.Black,Color.Green))
(Sets the button's color to grey, if approved and to black, if not approved and to green otherwise)
Best Regards,
Sven