Showing results for 
Search instead for 
Did you mean: 
Not applicable

Patching to more than one table

Is it possible to patch to more than one table by clicking one button?


I have a student behaviour management form where I want the information to go into a table called 'Records' but if the consequence is a lunch detention, that it also goes into a table called 'LunchDetentionRecords'.

BitLord69 Power Participant
Power Participant

Re: Patching to more than one table

Sure, no problem. Just make several calls to Patch in the button's OnSelect, separated by ;; (in Sweden we use ";;" to separate statements - this is country specific!!!)


In one of my apps I have the following code when pressing a button:


UpdateContext({rNewRecord: Patch('[dbo].[OnskelistaHuvud]'; Defaults('[dbo].[OnskelistaHuvud]'); {Bestallare:User().FullName};{BestEpost:User().Email};{Kommentar:txtComment.Text};{Bestallningsdatum:Today()})});;
ForAll(cItemList;Patch('[dbo].[OnskelistaRad]'; Defaults('[dbo].[OnskelistaRad]');{OnskelistaHuvudId:rNewRecord.Id}; {Setting the fields}...))

First I patch the main table, wrapped in a call to UpdateContext to save the resulted record so I can use the record's Id when I create linked records.

After that I loop through my list of items with ForAll and create related records by another call to Patch, setting the link field with the Id from the first statement. If you don't need to save an Id (create linked records) you don't have to wrap the first Patch in an UpdateContext.


Good luck!


Downside to this - there is no error checking!

Helpful resources


Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!


New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Apps Community!

Top Solution Authors
Top Kudoed Authors
Users online (6,249)