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

How to update text field and Choice field on the click of a button

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: How to update text field and Choice field on the click of a button

Hi @cooltechie,

Could you please share a screenshot about your app's configuration?

How do you update the Manager Approval field in your SP list via clicking "Approve" or "Reject" button?

You could consider take a try to add a Custom Data card within your Edit form (SharePointForm1), then add "Approve" and "Reject" button within the custom data card.

I have made a test on my side, please take a try with the following workaround:6.JPG

 

7.JPG

Add a Custom Data card within my Edit form (SharePointForm1), then add "Approve" button and "Reject" button within it.

Set the DisplayMode property of the "Approve" button and "Reject" button to following:

If(
ThisItem.'Created By'.Email in Office365Users.DirectReports(User().Email).Mail,
DisplayMode.Edit,
DisplayMode.Disabled
)

Set the OnSelect proeprty of the "Approve" button to following:

Patch('20181221_case7',ThisItem,{'Manager Approval':"Approved"});RequestHide()

On your side, you should type:

Patch('YourSPList',ThisItem,{'Manager Approval':"Approved"});RequestHide()

Set the OnSelect property of the "Reject" button to following:

Patch(
    '20181221_case7',
    ThisItem,
    {
      'Manager Approval':"Rejected",
       Status: {
           Value: "In Progress"
       }
    }
);
RequestHide()

On your side, you should type:

Patch(
    'YourSPList',
    ThisItem,
    {
      'Manager Approval':"Rejected",
       StatusColumn: {
           Value: "In Progress"
       }
    }
);
RequestHide()

 

Set the OnNew property of the SharePointIntegration control to following:

Refresh('YourSPList');  /*<- Add this formula */
NewForm(SharePointForm1)

Set the OnEdit property of the SharePointIntegration control to following:

Refresh('YourSPList');  /*<- Add this formula */
EditForm(SharePointForm1)

Set the OnView property of the SharePointIntegration control to following:

Refresh('YourSPList');  /* <- Add this formula */
ViewForm(SharePointForm1)

In addition, currently within PowerApps, there is no direct way to make a Edit form read-only/disabled. As an alternative solution, you could consider make the Data cards within the Edit form (SharePointForm1) disabled when the Manager Approval column value is set to "Approved". Please take a try with the following workaround:

Set the DisplayMode property of the All Data cards within the SharePointForm1 (Edit form) to following:

If(
   DataCardValue4.Text="Approved", /*<- DataCardValue4 represents the Text Input box within the Manager Approval Field Data card*/
   DisplayMode.Disabled,
   Parent.DisplayMode
)

More details about making a Edit form read-only or disabled in PowerApps, please check my response within the following thread:

 

https://powerusers.microsoft.com/t5/Expressions-and-Formulas/How-to-make-a-Form-read-only-or-Disable...

 

Please check the attached GIF screenshot for more details:

 

More details about the Patch function, please check the following article:

Patch function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6

Re: How to update text field and Choice field on the click of a button

Hi

 

You have to set the defaut/text property of your field to a variable, for example _MyVar

Then, on the OnSelect property of your button, add Set(_MyVar;"Approved")

 

And on your form, set the DisplayMode with an if statement like If(ManagerApprovalField = "Approved", DisplayMode .Read, DisplayMode.Edit)

 

Hope it helps

 

Regards

cooltechie
Level: Powered On

Re: How to update text field and Choice field on the click of a button

Hello,

 

I tried this however, the value of the text input reverts to blank when opened again. Not sure what is going on.

 

 

Re: How to update text field and Choice field on the click of a button

I don't know if you submit the form or not. Please feel free to add screenshots of what you are doing

regards

cooltechie
Level: Powered On

Re: How to update text field and Choice field on the click of a button

Hello,

 

The text field value gets updated in SharePoint however, when I reopen the form, the text input control remains blank.

Super User
Super User

Re: How to update text field and Choice field on the click of a button

Hi @cooltechie

 

For the Default/Text item, have it check whether the FormMode is New or Edit, if it's Edit then use existing value (Parent.Default), or else use the variable name you set:

 

If(
   WhateverFormName.FormMode = FormMode.Edit ,
   Parent.Default ,
   _MyVar
  )

 

Cheers,

@iAm_ManCat




Don't forget to 'Mark as Solution' if a post answered your question and always 'Thumbs Up' the posts you like or helped you!
Community Support Team
Community Support Team

Re: How to update text field and Choice field on the click of a button

Hi @cooltechie,

Could you please share a screenshot about your app's configuration?

How do you update the Manager Approval field in your SP list via clicking "Approve" or "Reject" button?

You could consider take a try to add a Custom Data card within your Edit form (SharePointForm1), then add "Approve" and "Reject" button within the custom data card.

I have made a test on my side, please take a try with the following workaround:6.JPG

 

7.JPG

Add a Custom Data card within my Edit form (SharePointForm1), then add "Approve" button and "Reject" button within it.

Set the DisplayMode property of the "Approve" button and "Reject" button to following:

If(
ThisItem.'Created By'.Email in Office365Users.DirectReports(User().Email).Mail,
DisplayMode.Edit,
DisplayMode.Disabled
)

Set the OnSelect proeprty of the "Approve" button to following:

Patch('20181221_case7',ThisItem,{'Manager Approval':"Approved"});RequestHide()

On your side, you should type:

Patch('YourSPList',ThisItem,{'Manager Approval':"Approved"});RequestHide()

Set the OnSelect property of the "Reject" button to following:

Patch(
    '20181221_case7',
    ThisItem,
    {
      'Manager Approval':"Rejected",
       Status: {
           Value: "In Progress"
       }
    }
);
RequestHide()

On your side, you should type:

Patch(
    'YourSPList',
    ThisItem,
    {
      'Manager Approval':"Rejected",
       StatusColumn: {
           Value: "In Progress"
       }
    }
);
RequestHide()

 

Set the OnNew property of the SharePointIntegration control to following:

Refresh('YourSPList');  /*<- Add this formula */
NewForm(SharePointForm1)

Set the OnEdit property of the SharePointIntegration control to following:

Refresh('YourSPList');  /*<- Add this formula */
EditForm(SharePointForm1)

Set the OnView property of the SharePointIntegration control to following:

Refresh('YourSPList');  /* <- Add this formula */
ViewForm(SharePointForm1)

In addition, currently within PowerApps, there is no direct way to make a Edit form read-only/disabled. As an alternative solution, you could consider make the Data cards within the Edit form (SharePointForm1) disabled when the Manager Approval column value is set to "Approved". Please take a try with the following workaround:

Set the DisplayMode property of the All Data cards within the SharePointForm1 (Edit form) to following:

If(
   DataCardValue4.Text="Approved", /*<- DataCardValue4 represents the Text Input box within the Manager Approval Field Data card*/
   DisplayMode.Disabled,
   Parent.DisplayMode
)

More details about making a Edit form read-only or disabled in PowerApps, please check my response within the following thread:

 

https://powerusers.microsoft.com/t5/Expressions-and-Formulas/How-to-make-a-Form-read-only-or-Disable...

 

Please check the attached GIF screenshot for more details:

 

More details about the Patch function, please check the following article:

Patch function

 

Best regards,

Kris

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (4,774)