cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cooltechie
Helper IV
Helper IV

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
v-xida-msft
Community Support
Community Support

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
Anonymous
Not applicable

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

Hello,

 

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

 

 

Anonymous
Not applicable

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

regards

Hello,

 

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

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

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


v-xida-msft
Community Support
Community Support

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.

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PWREduCon768x460.png

Join us at PWR EduCon - A Power Platform Conference

Learn from the top Power BI, Power Apps, Power Automate & Power Virtual Agents experts!

Top Solution Authors
Top Kudoed Authors
Users online (2,529)