Showing results for 
Search instead for 
Did you mean: 
Super User
Super User

How did Patch know that i need to edit a record a not update it

I have a PopUp with only one field >>and a save button >> inside the Save button i have the following formula inside the OnSelect:-


Path(ParentTable,Gallery1.Selected, {Quantity: NewQTY.Text});


now the Patch will update the related record inside the parent table.. so how did the patch know that i want to edit the Quantity of existing record and that i do not want to create a new record with the passed quantity ?


Super User
Super User

Hi @johnjohn123 

If you pass 2 arguments to the Patch function (like in your example), the patch function merges the two records which effectively results in the edit behaviour that you see.


To create a new record with the passed quantity, you would need to supply Defaults(DataSource) as the second argument to Patch.


There are more details about the merge behaviour in the documentation here:




Super User
Super User

Because you are not writing Defaults keyword which is necessary to make new records. and also you are specifying specific record. That's how it knows that you want to edit and not create

Super User
Super User

Hi @johnjohn123 


All you have to is from the record your navigating from just onSelect like this code 


Editing record onSelect 




New record creating button 







On the Form Screen add this The Form DefaultMode 





Form Item property 







Patch button



Patch(YourListName,varItemShipment,{Quantity: NewQTY.Text});



Please change the names to field screen names 

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.

@zmansuri  can i know what do you mean by "and also you are specifying specific record. " .. for examplw I could specified a record and add it... Is it this correct? i do not think specifying an item means that it will get edited instead of created..

@timl  so can i say that 2 arguments means edit ,,, while 3 arguments means create?


Super User
Super User


To clarify, calling Patch with 2 arguments will never add a record to a data source.

Calling Patch with 3 arguments can either create or update an existing record. If the 2nd argument includes a call to the Defaults function, Patch will create a new record. If the 2nd argument specifies an existing record, Patch will update the record.

@timl  is there any official documentation about you statement?


Helpful resources

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.


New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (3,600)