cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cooltechie
Level: Powered On

How to set a Choice field value on a Button click

Hi,

 

I have a SharePoint  list form that is customized using Power Apps and I have a Form status Choice field with two Values "In Progress" and "Ready for Review".  I also have another Text field called Manager Approval.

 

I do have two buttons on the form, one is "Approve"  and the other is "Reject". I expose "Approve" and "Reject" buttons only if the logged in user is the manager of the person who created the sharePoint list item.

 

When the Manager clicks on "Approve", I would like to set the Manager Approval field to "Approved".

When the Manager clicks on "Reject", I would like to set the Manager Approval field to "Rejected" and set the Form Status field back to "In Progress". 

 

Also, I would like the entire form to be read only if the Manager Approval field = Approved.

 

Please advise how to achieve this in Power apps.

5 REPLIES 5
Community Support Team
Community Support Team

Re: How to set a Choice field value on a Button click

Hi @cooltechie,

 

Set the OnStart property of the app to:

Set(V1,FormMode.Edit)

Set below formulas on the DefaultMode property of the Form control:

V1

For the "Approve" and "Reject" buttons, set below properties:

Button1.Visible=If(User().Email="Manager1@contoso.com",true,false)

Button2.Visible=If(User().Email="Manager1@contoso.com",true,false)

Buttion1.OnSelect=Patch(ListName,Defaults(ListName),{Title1Smiley Very HappyataCardValue1.Text,ManagerApproval:"Approved"});Set(V1,FormMode.View)

Buttion2.OnSelect=Patch(ListName,Defaults(ListName),{Title1Smiley Very HappyataCardValue1.Text,
ManagerApproval:"Reject"
Status:
 {'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
 Id:1,
 Value:"In Progress"}
 }})

Notice that you need to include all the Required fields from SharePoint list for Patch formula. I just added the Title field as an example in above formulas.

 

Regards,

Mona

 

 

 

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
cooltechie
Level: Powered On

Re: How to set a Choice field value on a Button click

 

Hi Mona,

 

Let me try this.

cooltechie
Level: Powered On

Re: How to set a Choice field value on a Button click

When you say "OnStart" property of the app, do you mean the Form control's OnStart property?

cooltechie
Level: Powered On

Re: How to set a Choice field value on a Button click

Also, I do not see DefaultMode property of the FormControl. This property doesn't exist for Form Control

TimRohr
Level 10

Re: How to set a Choice field value on a Button click

You will find OnStart for your app if you highlight the first screen in your app in the left-hand tree of controls. Highlight the screen, then look to the menu bar on the top. Under "Action" you will have an OnStart property in which you can put code.

 

As for the DefaultMode of a form, you have to look at the Advanced properties sheet. Once you have the form selected, then find and click on Advanced in the right-hand pane. DefaultMode will be the second property under the Data section.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 55 members 4,354 guests
Please welcome our newest community members: