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 / Patch to add or edit r...
Power Apps
Answered

Patch to add or edit record in SP List

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

 

I'm trying to figure out how I can add or edit a record using patch. I am currently  using one form to add or edit, however upon checking while using the patch function it doesn't do both it only edit the data. Hoping someone can help me out on what formula should I use to add/edit a record using patch.

 

Thanks in advance 🙂

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    if you are using a form, you can use the function "NewForm" for add a new record and then EditForm to edit that record. 

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

    Hi @Anonymous,

    How do you submit your form data into your SP list using Patch function? Could you please share a bit more about the formula?
    I have made a test on my side, please take a try with the following workaround:

    7.JPG

    Set the OnSelect property of the "Submit" button to following formula:

    If(
      EditForm1.Mode=FormMode.New,
     Patch('20181026_case11',Defaults('20181026_case11'),EditForm1.Updates), /* <-- '20181026_case11' represents the SP list data source in my app*/
     Patch('20181026_case11',BrowseGallery1.Selected,EditForm1.Updates)
    )

    Note: The EditForm1 represents the Edit form within my app. And within the first screen of my app, I use a Gallery control (called BrowseGallery1) to list all records of my SP list datasource.

    On your side, you should type the following formula:

    If(
      EditForm1.Mode=FormMode.New, /* <-- EditForm1 represents the Edit form control within your app */
     Patch( /* <-- Add a new record */
    'YourSPList',
    Defaults('YourSPList'),
    EditForm1.Updates
    ), Patch( /* <-- Modify an existing record */
    'YourSPList',
    'Type Item property formula of your Edit form', /* If you don't use a Gallery to list all your SP list records, you should type the Item property formula of the Edit form*/
    EditForm1.Updates
    ) )

    Or

    If(
      EditForm1.Mode=FormMode.New, /* <-- EditForm1 represents the Edit form control within your app */
     Patch( /* <-- Add a new record */
    'YourSPList',
    Defaults('YourSPList'),
    {
    Column1: DataCardValue1.Text,
    Column2: DataCardValue2.Text,
    ...
    }
    ), Patch( /* <-- Modify an existing record */
    'YourSPList',
    'Type Item property formula of your Edit form', /* If you don't use a Gallery to list all your SP list records, you should type the Item property formula of the Edit form*/
    {
    Column1: DataCardValue1.Text,
    Column2: DataCardValue2.Text,
    ...
    }
    ) )

    Note: 'The Item property formula of your Edit form' represents the existing record you want to modify within your Edit form. You could also find the corresponding record you want to modify using LookUp function based some conditions.

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

    Patch function

    When you use the Patch function to modify an existing record, you must find the record firstly, then put it on the second parameter value of the Patch function (as mentioned above).

     

    Best regards,

    Kris

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 549 Most Valuable Professional

#2
Kalathiya Profile Picture

Kalathiya 225 Super User 2026 Season 1

#3
Haque Profile Picture

Haque 224

Last 30 days Overall leaderboard