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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch function in Shar...
Power Apps
Unanswered

Patch function in SharePoint List Custom Form overwriting existing records in SharePoint List

(0) ShareShare
ReportReport
Posted on by 79

I have created a multiple screen custom form for a SharePoint list. Each screen contains a form. In order to ensure all forms save to the SharePoint list, I have disabled the default save button on the form and created my own "save" button which appears on each form. I have used the patch function, using the formula below:

 

Set(varRecord, Patch(
'T-O Led Projects',
{ID:SharePointIntegration.SelectedListItemID},
SharePointForm1.Updates,
SharePointForm1_1.Updates,
SharePointForm1_2.Updates,
SharePointForm1_3.Updates,
SharePointForm1_4.Updates,
SharePointForm1_5.Updates));
Navigate('Success Screen');

 

This seems to work fine when users edit an existing record.

However, when users try to add a new record, and then use this save button, it appears to overwrite the first item in the SharePoint list. When I look at the version history for the record, I can see all the old data being replaced by the new entry.

 

Why is my custom save button behaving like this?

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @FarmingBA ,

    For a new record, you need to replace

    {ID:SharePointIntegration.SelectedListItemID},

    with

    Defaults('T-O Led Projects'),

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • FarmingBA Profile Picture
    79 on at

    Thanks Warren.

     

    I want to use the same form for creating new records and editing existing ones. Therefore, the Save button (patch formula) will always be the same.

     

    If I amend the formula as you suggest, will the Save button continue to work as it does now for editing existing records?

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @FarmingBA ,

    No - and that is unfortunately what happens when you go down the Patch(Form.Updates) track rather than submitting the Forms, which will write according to their Form Mode. You may have to set a Variable for when you want a new record, and then conditionally send the relevant code.

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • FarmingBA Profile Picture
    79 on at

    Thanks Warren. Is it straight-forward to set up that Variable for new records? I would be grateful if you could point me in the right direction.

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @FarmingBA ,

    Example - for new set to true, for Edit set to false

    UpdateContext({varNew: true})

    and then your Patch

    Set(
     varRecord, 
     Patch(
     'T-O Led Projects',
     If(
     varNew,
     Defaults('T-O Led Projects'),
     {ID:SharePointIntegration.SelectedListItemID}
     ),
     SharePointForm1.Updates,
     SharePointForm1_1.Updates,
     SharePointForm1_2.Updates,
     SharePointForm1_3.Updates,
     SharePointForm1_4.Updates,
     SharePointForm1_5.Updates
     )
    );
    Navigate('Success Screen');

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard