web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create records in two ...
Power Apps
Answered

Create records in two tables from the screen

(1) ShareShare
ReportReport
Posted on by 8

Hi,

 

I'm wondering if there is way to create new records from the single screen/form. I have two related tables - Employee and OnBoarding. There are fields on the screen that will be filled in by the new employee and new onboarding information.

What I want to achieve is to save the records in the corresponding tables when all info is populated on the form. In other words, instead of creating employee records using two different screens, save them from one screen.

 

Thanks!

 

Categories:
I have the same question (0)
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Andrew88 

     

    Use this function

     

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-patch

     

    Patch

     

    Modifies or creates one or more records in a data source, or merges records outside of a data source.

     

    Use the Patch function to modify records in complex situations. Such as, when you do updates that require no user interaction or use forms that span multiple screens.


    Then you can use one screen.

     

    If above is not enough, reply here and in that case more detail might be given for your scenario.

     

  • Andrew73 Profile Picture
    8 on at

    Thank you for the reply. I already read about this function, but unfortunately can't find any samples/scenarios in documentation on how to use it with the form's data. 

     

    For example I have three fields on the form that I want to be save in two tables, Employee Code, Employee Name and Onboarding Comment, does this form has to be linked to the datasource? How to read the values in the text fields and pass them to the patch function, how patch function should handle them?

     

    Thanks!

  • Verified answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @Andrew88 

     


    @Andrew88 wrote:

    Thank you for the reply. I already read about this function, but unfortunately can't find any samples/scenarios in documentation on how to use it with the form's data. 

     


     

    Then you can check this specific example. It is being modeled with two SharePoint Lists but it can be applied with two Dataverse Tables as well.

     

    First, make sure that if you use multiple Forms, that their DefaultMode is set to FormMode.New for both of them

     

    joeishere-formmode-new.png

     

     

    Then, the main task would be to match up Controls with the right values in them, with columns from the data source. In an example of a SharePoint List set up as follows:

     

    sp1.png

    and yet another SharePoint List set up as follows:

     

    sp2.png

    and presuming two SharePoint List Data Sources set up correctly in the app:

     

    sdatasource-joeishere-ex.png

     

    and as mentioned, also presuming two Forms with FormMode.New as the DefaultMode on both forms,

     

    and finally, presuming one button - you would put something like this in the OnSelect of that button to save the records to different tables:

     

     

    Patch(Employee,{'Title': DataCardValue1.Text,'Employee Name':DataCardValue3.Text,'Employee Code':DataCardValue2.Text});
    Patch(OnBoarding,{'Title': DataCardValue5.Text,'OnBoarding Comment':DataCardValue6.Text});

     

     

    If your data source requires any columns as a business rule or otherwise on the server side somehow, those MUST be provided in the Patch function or you may get error in runtime. In our example, the Title field of SharePoint list is always required on the data source level, so we must provide it, or we do get a runtime error in our case if we were to omit this from either Patch function. In Dataverse this also may apply to any Table where any columns are marked as Business Required on them - for those the columns may have to be possibly specified and provided with a value in the Patch function.

     

    You can see it working in the following graphic example below as well:

     

    joeishere-v1.gif

     

     

    Check if something like the above helps.

     

     

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard