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 / Why is Patch creating ...
Power Apps
Answered

Why is Patch creating a new record when I don't use Defaults?

(0) ShareShare
ReportReport
Posted on by

 

Hello all!

 

I have a PowerApp where you can view records in a Gallery by selecting them, and in the next screen there is a tiny 'Edit' icon in the top-right that lets you modify details of that item you selected. 

 

jharville_0-1674852913183.png

 

When you click on that Edit icon, it takes you to a screen that has an Edit Form. In that Edit Form screen, there is a 'checkmark' in the top-right that resubmits the form (using a Patch function). Here is the code behind the OnSelect of the submit button on the next screen:

 

jharville_2-1674853081564.png

 

 

jharville_1-1674852959488.png

 

When submitted, it updates that existing record (which is good), but also creates a new one. Why is it doing this even though I'm not using Defaults? Maybe because I didn't include 'Attachments' in the patch? How would I fix this?

 

jharville_3-1674853159035.png

 

 

 

Thank you so much!

 

J

 

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,748 Most Valuable Professional on at

    Hi @jharville ,

    The thing I am wondering here is how it actually updates the existing record as you have not referenced it in the Patch. You do not need Defaults() to create a new record - it is inferred unless you specify an existing record to Patch (so the new record is not a surprise). I can see you have commented out the SubmitForm - this is all you really need to update the existing record - do you have any other code running here ? Also if you selected the record from a Gallery, you can do this

    Patch(
     'Operator Connect Log'
     {ID: GalleryName.Selected.ID},
     {
     'Operator Name': DataCardValue5.Text, 
     'Restaurant Number': DataCardValue6.Text, 
     City: DataCardValue7.Text,
     State: DataCardValue8.Text,
     'Notes For Follow Up': DataCardValuelQ.Text, 
     'Followed Up?': Checkbox2.Value
     }
    )

    Lastly, please post your code in Text - saves OCR or a lot of typing this end.

     

    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

  • jharville Profile Picture
    on at

     

    Hi @WarrenBelz 

     

    Thank you so much for the response, I will for sure be attaching the code in Text next time. So essentially, we have a gallery ('Gallery4') that displays records that are clickable that will take you to each record's view screen (as showed in my first screenshot of my previous message). Once you have that record's details open, I would like to include the option to edit that record, hence the 'edit icon' in the top right corner. Once that icon is clicked, it takes you to an Edit Form (I greyed out the rest of the fields and only want the user to be able to change the 'Followed Up?' field)...

     

    ... I then put your code into the 'check-mark icon' that submits the changes and ideally should patch updated info to that same existing record, not create a new one. This is the error that came up:

     

    jharville_0-1675060424190.png

     

    jharville_1-1675060460451.png

     

    It makes sense we need to reference the existing record's ID to specify which item in our SP List to have those changes sent to, but it's not liking that ID reference we included in the code.

     

     

  • jharville Profile Picture
    on at

    I actually forgot a comma lol ~ testing out your solution right now.

  • jharville Profile Picture
    on at

    Your solution was spot on, will be sure to reference the ID from selected gallery record in future patches, missed out on that small detail. Thanks again!

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard