web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Update SharePoint item
Power Apps
Unanswered

Update SharePoint item

(0) ShareShare
ReportReport
Posted on by 383

Hi Power Apps Community,

Issue: I have a Power Apps page where two Patch functions are used - executed on two separate buttons.

The first Patch creates new records in SP, and the second Patch should add the comment that is added to the created items from the first Patch.

I have a column in my SP List called 'Comments'. But I am unable to add / update the comments to the associated list item. 

I would appreciate any assistance on this.

Thank you in advance.

Categories:
  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    Hi @Data_Enthusiast ,

    What is your second Patch code?

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Data_Enthusiast ,

    Does the second Patch function would update the previous submitted record (through the first Patch function) with Comments?

     

    Based on the needs that you mentioned, I think a global variable could achieve your needs. You could consider save your first Patch formula result into a variable, then within your second Patch formula, you could edit the previous submitted record based on the variable.

     

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

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

    Set(
     SubmittedRecord,
     Patch( // Type your Patch formula here
     'Your SP List', 
     Defaults('Your SP List'), 
     {
     Title: "xxxx",
     Column2: TextInput2.Text,
     Column3: TextInput3.Text,
     ...
     }
     )
    )

     

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

    Patch(
     'Your SP List',
     LookUp('Your SP List', ID = SubmittedRecord.ID), // Reference the Item ID from the saved SubmittedRecord variable
     {
     Comments: CommentTextBox.Text
     }
    )

     

    Please take a try with above solution, check if the issue is solved.

     

    Best regards,

  • Data_Enthusiast Profile Picture
    383 on at

    Hi @WarrenBelz 

    I used:

    Patch('SP List', {Comments: CommentTextBox.Text}) 

    I'm aware that using 'Defaults' creates a new entry, so I though leaving it out would update existing records. 

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    Hi @Data_Enthusiast ,

    You have not told PowerApps which item to Patch - I also prefer UpdateIf

    You can get this information from the LastSubmit function. - Change form name to your new form name. Bear in mind that this will work only in the same session as the new form is submitted and will be the last record submitted by that form.

    UpdateIf(
     'SP List', 
     ID = YourNewRecordFormName.LastSubmit.ID,
     {Comments: CommentTextBox.Text}
    ) 

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Data_Enthusiast Profile Picture
    383 on at

    Hi @v-xida-msft 

    I tried your script but nothing gets Patched to the SharePoint list.

    The items are in a Gallery, with each item having a comment icon. Once you select the icon, one pop up box shows for the selected item.

  • Data_Enthusiast Profile Picture
    383 on at

    Hi @WarrenBelz 

    I tried the provided script. 

    I get an error message for the '=' sign saying that it is an "Invalid argument type".

  • WarrenBelz Profile Picture
    156,566 Most Valuable Professional on at

    @Data_Enthusiast ,

    Please tag whoever you want to respond here as three way conversations do nothing but confuse everyone, however the error does not seem logical as you are simply comparing one numeric value with another.

    If you want me to continue with this (as above), please supply the actual code you have used.

  • Data_Enthusiast Profile Picture
    383 on at

    Hi @WarrenBelz 

    I am not using a form. 

    The Gallery is referenced by a Collection - which is referencing the SP List.

    UpdateIf(
     'SP List', 
     ID = SP List / Collection.LastSubmit.ID
     {Comments: RichTextEditor.HtmlText
    )

    I tried to reference both the SP List and Collection respectively, but both did not work. 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard