Get the ID of a record just patched in Power Apps
Read Time:2 Minute, 25 Second

Get the ID of a record just patched in Power Apps

In this post, I’ll show you how to get back the ID of a record you’ve just patched whether that be to create a new record or edit an existing record!

This will mainly be helpful for those new records you’re using Patch() to create though, as with an existing record, it’s likely that you already have the record ID.

Adding my data sources

So I’ve just created a new app, and I’m going to add two data sources to demonstrate this. I’m going to add a SharePoint data source and a Dataverse table.

Now I’m going to add two buttons on my screen. One to do my SharePoint patch, and one to do my Dataverse patch. Using the OnSelect property of these buttons, I’m then very simply going to use Patch() to create a new record, and I’m just going to provide the title field and leave the others blank.

In my patch for my SharePoint record, I’m going to use this formula for my OnSelect of my SharePoint patch button:

Patch('Issue tracker',Defaults('Issue tracker'),{Title: "New Patched Record"})

Then for the dataverse one…

Patch(Accounts,Defaults(Accounts),{'Account Name': "New Patched Record"})

Awesome! I’m now creating my records.

Using Set() to store our record back into a global variable

So… I’ve patched my records but I still don’t have an ID of those new records I’ve just created to now be able to utilise in my app to say pass into a flow as an input or do something else with.

We’re going to use a very simple trick to get the record we’ve just patched back and store it in a global variable to be able to access its data.

Let’s wrap a Set() function around our Patch() and set our patched record into a global variable. So now my formula looks a little more like this…

Set(gblLastPatched,Patch('Issue tracker',Defaults('Issue tracker'),{Title: "New Patched Record"}))

Or for Dataverse… like this…

Set(gblLastPatchedDataverse,Patch(Accounts,Defaults(Accounts),{'Account Name': "New Patched Record"}))

Proving it works!

So I’ve now clicked these two buttons and my data should hopefully be stored in my global variable. But how do we check this? I’m going to add 2 labels to my screen now.

Using the text property of those labels I’m going to use dot notation to access the properties/columns against the record stored in my global variables. I want to see the ID so my labels are going to use the following formulas to get the SharePoint list item ID back and the Dataverse Account record GUID.


and for Dataverse…


Now my labels are populated with ID values! Awesome! These are the ID’s of my just patched records

Hopefully you found this post helpful! If you’ve got any questions on this topic, or want to hear about another topic, let me know!

Leave a Reply

man love people woman Previous post Parse JSON in Power Automate
person holding black phone with bokeh photography background Next post Increase user adoption of Power Platform solutions
%d bloggers like this: