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 / How to add item by usi...
Power Apps
Answered

How to add item by using “Patch”? (how to grab SharePoint list item?)

(0) ShareShare
ReportReport
Posted on by 152

I’m building PowerApps app with 2 screen.

As data source, I’m suing SharePoint list named “Events”. In this SharePoint list, I have 10 columns.

At screen1, I’m using Form control and wants users to enter value for column 1 to 5. Other columns such as 6 to 10 should be unselected, hide from form control.

I put SAVE button on screen1 so that user should save all input by “SubmitForm” function.

SAVE button also navigate user to move Screen2 and I put InputBox for column 6 to 10 and want to use “Patch” all user inputs to the same line of SharePoint list items.

Submitting form on screen1 is OK, surely created SharePoint list item but at the next screen 2, I cannot successfully grab same list item. How should I write “Patch” to add items on a same list item?

Categories:
  • ThatAPIGuy Profile Picture
    925 on at

    @Sam44

     

    This might be helpful - 

     

    Patch( Events, Defaults( Events), Form1.Updates,Form2.Updates)

    defaults function in the patch will create a new row/record and then updates from Form1 and Form2 will be patched

  • CU-21080815-8 Profile Picture
    152 on at

    @ThatAPIGuy

    Thanks for your help!

    I'm using Patch but my question is once user submmited Form1 on screen1 then move to screen 2 which only has "Inputbox", how I can update same line of record items since only I can get is Form1.LastSubmit.ID?

    If I write like : Patch(Events, Defaults(Events), Column6:InputboxA_on the Screen2), this create "new" SharePoint list item.

    How I can "Add" values in Inputbox to exsisting list item record is my question need to be solved.

     

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @Sam44,

     

    in reality, you want the "edit" the record that you just created by patching in the text of your inbox.  The patch function is different for creating a new record vs. editing a record. On your first screen you are creating the new record so Defaults() is used for creating a new record in your data source.  For editing that record, you need to identify it for the Patch command in the second screen.. One way is to have the Patch(Events, Last(Events), {Column6:InputboxA_.Text}).  This will work if your Events table has 2000 records or less.  I personally prefer to use First(Sort(... in case the data source grows to more than 2000 items.

     

    In your case, it would be Patch(Events, First(Sort(Events,ID,Descending)), {Column6:InputboxA_.Text})  // You would have this command in the OnSelect property of the button on your 2nd screen. 

     

    Tip:  Check out the Patch() function information at https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

     

     

     

     

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

    Hi @Sam44,

     

    Do you want to save your form data within the second screen into the same SP list item record the previous form submitted using Patch function?

     

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

     

    2.JPG

     

     

    Set the OnSelect property of the "Save" button within the first screen to following formula:

    SubmitForm(Form1);Navigate(Screen2,ScreenTransition.Fade)

    Note: The Form1 represents the Form control within the first screen.

     

    Set the OnSelect property of the "Patch"  button within the second screen to following formula:

    Patch(
     '20180907_case9',
     Form1.LastSubmit,
     {
     Status: {
     '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id: 0,
     Value: DataCardValue10.Selected.Value
     },
     Department: DataCardValue11.Text
     }
    )

    On your side, you should type the following formula:

    Patch(
    Events,
    Form1.LastSubmit,
    {
    Column6:DataCardValue6.Text,
    Column7:DataCardValue7.Text,
    ...
    Column10:DataCardValue10.Text
    }
    )

    Note: The Form1 represents the Edit form within your first screen. 

     

    The GIF screenshot as below:Test1.gif

     

     

     

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

    Patch function

     

     

    Best regards,

    Kris

  • CU-21080815-8 Profile Picture
    152 on at

    Thanks @v-xida-msft !

    Yes, I made it with your code!!

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 232 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 202 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard