Showing results for 
Search instead for 
Did you mean: 
Power Participant
Power Participant

Using the values returned by behaviour formulas (i.e. Patch)

How can we read/use the values returned by behaviour formulas such as Patch?


The reference article mentions this: "The return value of Patch is the record that you modified or created. If you created a record, the return value may include properties that the data source generated automatically."


I am not sure how to get the return value when associating a patch with an OnSelect of say a button.  This is useful to get the auto generated ID of a new item from a SharePoint list for example.


Accepted Solutions

That's a very strong assumption. It may work. But the right way to do it is to simply UpdateContext the return value of Patch

UpdateContext({Submitted: Patch(....)})

View solution in original post




You can use “Navigate(ViewScreen,ScreenTransition!Fade,{Record:ThisItem})” to create a record.


A detailed demo about how to browse for a record, display details about that record, and edit or create a record:




Dean Wang

Dean, thank you for your response. From my understanding of your response you have shown an alternative way to create a record. I'm in a similar position to the orignal poster. 


If i use the Patch(DataSource, Defaults... command, how do I get the record ID on the newly created record? I need it because I want to pass on this new record ID to the next screen so that I can continue patching in more data into the newly created record.


I can't seem to find any information on how to colleact these values that are returned from running these commands.

Community Champion
Community Champion

Hi @UB400

This is Steelman70, but I changed my username.

I have found how to do this, and it seems to work.

Basically, once you Patch with Defaults, your newly created record is the last in the data source, so what I do is to add an UpdateContext to get the ID of the last record in the data source.  This should be the OnSelect of your save button:

Patch(MyDataSource, Defaults(MyDataSource), {MyColumn1: MyData etc....}); UpdateContext({MyNewlyCreatedRecordID: Last(MyDataSource).ID})

Please let me know if this works for you too.

That's a very strong assumption. It may work. But the right way to do it is to simply UpdateContext the return value of Patch

UpdateContext({Submitted: Patch(....)})

View solution in original post

Community Champion
Community Champion

Wow @murali, thank you!  I had been waiting for that answer for about 3 months (my first post on this topic on the documentation page and this thread as Steelman70)

As @UB400 mentioned, there is no indication of this anywhere in the documentation, at least that I have found.

Many thanks!

Thank you @murali I really appreciate yours and @Steelman70 input. My apologies for my follow up question (I'm still very new to PowerApps).


This is the formula I came up with:


UpdateContext({Submitted: Patch(ConsultantList, Defaults(ConsultantList), {Title:" ",ConsultantFullName:TextInput1.Text,ConsultantAddressLine1:TextInput2.Text,ConsultantAddressCity:TextInput3.Text})});Navigate( Screen7, None,Submitted)


I'm able to see the value of the submitted.ID on the same page after the above command runs, but I'm not quite sure how to pass it on to the next screen. When I add a Textbox on the new screen and use Submitted.ID as the "Text" value, I get the yellow triangle for invalid name.


Please advise.

Context variables are bound to the screen on which they are created. They can however be passed around to other screens via Navigate. 


e.g. Navigate(Screen7, ScreenTransition.None, {Submitted: Submitted})


which stands for: take the value of Submitted and pass it to Screen2. On Screen2, you can now use Submitted just like before.


Hope this helps.




Community Champion
Community Champion

@murali is ablsoutely correct.

I just wanted to add to be careful when using the same context variable name in two or more different screens.  If you then change the value of the variable in the second screen for any reason, the value of that variable in the other screens is not affected.

Basically you can end up in a situation where one context variable has a different value in each of your screens where it is used.

To avoid this confusion I normally do not use the same context variable name in two different screens:

e.g. Navigate(Screen7, ScreenTransition.None, {Returned: Submitted})

@murali and @Meneghino thank you so much for your help with this. That works! You guys are awesome.

Helpful resources

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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