Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

Using the Patch function to either create OR update a record

Hi, we are developing a free system that allows to coordinate the efforts of volunteer rescue and emergency groups working in a disaster or conflict zone. For us it's extremely important to be able to know where our medics and support teams are located. Since they use a PowerApps to create a report for every patient they attend, we incorporated into this same app a formula that is triggered with the OnVisible event and that sends us their location so it can be stored in a SharePoint list and then shown in a Power BI map. This is the formula to report their location  


Patch('SharepointList',Defaults('SharepointList'), {Title:"Title", Latitud:Location.Latitude,Longitud:Location.Longitude})


This formula is working great, however it creates a separate record every time. We would like to alter this formula to evaluate if the current user already has a location record in the list or not, and to create a record if it doesn't already have one or modify it if a record for this user already exists. This way we would only have the most update location for the user.


Any help with this would be greatly appreciated.


Best regards.




hi there, did you ever find a solution to this? I'm having the same issue... 

Hello J. Yes, it's the post marked as a solution here. That worked for me. I hope it does for you.



Not applicable



I am a newbie in Power Apps. I only wanted to save records into an Excel file when I press a button.

I am quite confused of how to do it.


What code should I use? and how the syntax arrangements will be?



I created my own form to begin with. I wanted to save the input data from that form to a local EXCEL file that I have



Not applicable

Hi @Meneghino 


I have a problem when pressing the Send button, the form should be reset. When you add a new item, it is added to the list as a new item and not merged with the last item saved in the list.
How can I press the Send button? The form is reset as if I opened the application again.
Note that I used ResetForm but unfortunately did not work.

Thank you.

@Meneghino Awesome code! Simple and worked like a charm !


How I could not figure this out earlier ...


Anyway, all credits to your solution, added to dev. pattern inside company over here.


Cheers and thanks a lot!

Hi All,
@gcanelon  @Meneghino 
I have a Leave Application, in which I am using two lists.

List 1) LeaveRequests

List 2) EmployeeLeaveBalance.

When the user comes in my app, it requests for Leave, Let's say Annual Leave and fill out the information in the form and press on the submit button,
the Submit button The First Patch Command  first patches in the LeaveRequests List of that User, which stores (User Email, LeaveType, Description, Manager Email, Start Date and End Date). and after that another Patch Command runs which, patches that user's Leave Balance in the EmployeeLeaveBalance List which Stores (User Email, Total Leaves, Annual Leave balance and Days Requested).

Now, I want to save only 1 record for each employee and then if he/she requests again. So, I want to update the EmployeeLeaveBalance List and update their LeaveBalance Column Everytime which is Subtracted from their Days Requested.

how to do this, Any help in this Regard.


Hi @Meneghino,


How will the above code work in Excel table and Textbox as fields in Edit form ?

Helpful resources

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (11,767)