Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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

 

  • jharville Profile Picture
    on at
    Re: Why is Patch creating a new record when I don't use Defaults?

    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!

  • jharville Profile Picture
    on at
    Re: Why is Patch creating a new record when I don't use Defaults?

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

  • jharville Profile Picture
    on at
    Re: Why is Patch creating a new record when I don't use Defaults?

     

    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.

     

     

  • Verified answer
    WarrenBelz Profile Picture
    146,618 Most Valuable Professional on at
    Re: Why is Patch creating a new record when I don't use Defaults?

    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

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,618 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,957 Most Valuable Professional

Leaderboard