Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Patch Comments and Checkbox to SharePoint List

(0) ShareShare
ReportReport
Posted on by

Hi Experts,

 

I have a submit button that i'd like the OnSelect to patch whatever comments have been put into a textbox called 'Stage1Approval-Comments'

 

I also have an Agree and Disagree checkbox on the same screen, if one of those are checked, then the patch should enter either "1st Stage Approved" if agree is checked and if disagree is checked then it should display "1st Stage Rejected" in a SharePoint List column named Stage1ApprovalStatus and also the same text in the sharepoint list column named ChangeStatus

 

Please help!

 

Thanks in advance

Dave

  • hthpowerapper Profile Picture
    364 Super User 2024 Season 1 on at
    Re: Patch Comments and Checkbox to SharePoint List

    If you want to update an existing record in SharePoint, you need to use the Patch function in a slightly different way. Instead of using Defaults(YourSharePointList) (which is used to create a new record), you need to specify the record you want to update. In your case, it's Gallery2.Selected. Here's how you can modify your Patch function:

     

    Patch(
     YourSharePointList, // replace with your SharePoint list name
     Gallery2.Selected, // update the record selected in Gallery2
     {
     Title: "Some title", // replace with any mandatory field in your SharePoint list
     Stage1ApprovalStatus: If(
     CheckboxAgree.Value, 
     "1st Stage Approved", 
     CheckboxDisagree.Value, 
     "1st Stage Rejected"
     ),
     ChangeStatus: If(
     CheckboxAgree.Value, 
     "1st Stage Approved", 
     CheckboxDisagree.Value, 
     "1st Stage Rejected"
     ),
     Stage1ApprovalComments: 'Stage1Approval-Comments'.Text // replace 'Stage1Approval-Comments' with your TextBox's name
     }
    )

     

    I'm not exactly sure how you have your app set up but if this doesn't work for specifiying which record you could set a global variable in your onselect for you gallery....

    Maybe something like

    
    Patch(
     YourSharePointList, // replace with your SharePoint list name
     LookUp(MySharepointList, MyColumn = MyVariable)
     {
     Title: "Some title", // replace with any mandatory field in your SharePoint list
     Stage1ApprovalStatus: If(
     CheckboxAgree.Value, 
     "1st Stage Approved", 
     CheckboxDisagree.Value, 
     "1st Stage Rejected"
     ),
     ChangeStatus: If(
     CheckboxAgree.Value, 
     "1st Stage Approved", 
     CheckboxDisagree.Value, 
     "1st Stage Rejected"
     ),
     Stage1ApprovalComments: 'Stage1Approval-Comments'.Text // replace 'Stage1Approval-Comments' with your TextBox's name
     }
    )

     

    If this answers your question, please mark one of my replies as Accepted Solution

  • Dave-ITMan Profile Picture
    on at
    Re: Patch Comments and Checkbox to SharePoint List

    Hi @hthpowerapper ,

     

    Thanks for the response, where you've put "create a new record", apologies, I should have mentioned that previous to this screen, the user has selected the SharePoint List record from a Gallery named Gallery2 so can you advise how this needs to be adjusted to update the record based on Gallery2.Selected please?

     

    Regards

    Dave

  • hthpowerapper Profile Picture
    364 Super User 2024 Season 1 on at
    Re: Patch Comments and Checkbox to SharePoint List
    Patch(
     YourSharePointList, // replace with your SharePoint list name
     Defaults(YourSharePointList), // create a new record, replace with your SharePoint list name
     {
     Title: "Some title", // replace with any mandatory field in your SharePoint list
     Stage1ApprovalStatus: If(
     CheckboxAgree.Value, 
     "1st Stage Approved", 
     CheckboxDisagree.Value, 
     "1st Stage Rejected"
     ),
     ChangeStatus: If(
     CheckboxAgree.Value, 
     "1st Stage Approved", 
     CheckboxDisagree.Value, 
     "1st Stage Rejected"
     ),
     Stage1ApprovalComments: 'Stage1Approval-Comments'.Text // replace 'Stage1Approval-Comments' with your TextBox's name
     }
    )

    this code assumes that the checkboxes are mutually exclusive - that is, if the "Agree" checkbox is checked, the "Disagree" checkbox is not, and vice versa. If there's a possibility that both could be unchecked, you might want to add some validation to handle this case.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard