Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Unanswered

Pass parent parameter to child related new form field

(0) ShareShare
ReportReport
Posted on by 559

Hi guys,

 

I added a button to a subgrid command bar to open a new related form as a centered dialog. Pictures underneath will guide you through the goal i am trying to achieve.

 

Here is my Opleiding form witch has Extra Kosts related to it. To add the related extra costs i have a subgrid in the Opleiding form.

2021-12-08 11_08_14-.png

When Clicking the default "New Extra Kost" button it will open a "New Extra Kost Form" in a new full page.

Notice that in this form the "Extra Cost Training" by default is filled in.

2021-12-08 11_08_27-Extra Kost_ Information_ New Extra Kost - Power Apps.png

To have a better UX I added a button "New In Center Dialog" to the subgrid. This opens the form as a centered dialog. 

Notice that in this form the "Extra Cost Training" by default is not filled in.

2021-12-08 11_08_37-.png

 

This is my javascript to show the centered dialog

2021-12-08 11_09_12-Web Resource_ ExtraCostCentered - Microsoft Dynamics 365.png

 

I would need to pass the "Extra Cost Training" parent value to the centered dialog matching field within the javascript.

Anyone has a idea how to achieve this?

 

Best Regards,

Anthony

 

 

  • AnthonyD Profile Picture
    559 on at
    Re: Pass parent parameter to child related new form field

    @skoofy5 @cchannon ,


    I tried implementing both of your codes but without success. How should i emplement this i my scenario so i get a betted understanding how jscript works with powerapps?

    I added my tables to give a better view how my data is set up.


    Extra Kost
    2021-12-10 08_11_24-Power Apps _ Solutions - TBA Model Driven.png

    Opleiding

    2021-12-10 08_11_41-Power Apps _ Solutions - TBA Model Driven.png2021-12-10 08_11_41-Power Apps _ Solutions - TBA Model Driven.png

    Relationship

    2021-12-10 08_12_00-Power Apps _ Solutions - TBA Model Driven.png2021-12-10 08_12_00-Power Apps _ Solutions - TBA Model Driven.png

     I checked network traffic on clicking the default new extra kost button and this is what is passing:

    Inked2021-12-10 08_31_43-Opleiding_ Information_ Figma Basics - Power Apps_LI.jpg

    The field i am trying to populate is (the training object i am adding a extra cost to): cref8_extrakosttraining


    Best Regards,

    Anthony

     

     

  • skoofy5 Profile Picture
    480 on at
    Re: Pass parent parameter to child related new form field

    You just need to set data values - for lookups it something like this:

    var parentId = "Parent ID"
    var parentName = "Parent Name"
    
    var dataDefault =
    {
     "cref8_opleiding": parentId,
     "cref8_opleidingname": parentName,
     "cref8_opleiding_cref8_extrakost@odata.bind": "/cref8_opleidingen(" + parentId + ")",
    
    };
    
    var pageInput = {
     pageType: "entityrecord",
     entityName: "cref8_extrakost",
     formType: 2,
     data: dataDefault,
    }
    
    var navigationOptions = {
     target: 2,
     width: { value: 50, unit: "%" },
     position: 1
    };

     So you'll just need to grab the parent id and name.

  • cchannon Profile Picture
    4,702 Super User 2025 Season 1 on at
    Re: Pass parent parameter to child related new form field

    OK, yeah, the only way to get a subgrid on a a QuickCreate would be to make your own in a PCF, so that defeats the purpose of going the OOB way. In that case, make the button with the ribbon workbench as noted above and pass the PrmaryControl value to your script. It will allow you to create a formContext obj that will give you everything you need to pass to the child form.

  • AnthonyD Profile Picture
    559 on at
    Re: Pass parent parameter to child related new form field

    @cchannon

     

    The reason i am trying to use the center dialog is because i have a related data subgrid  in the bottom of the form. I haven't yet found how to add subgrids in side panels so that's why i am trying to go for centered dialog form. If there would be a better way to add related data i would love to hear your suggestions.

    2021-12-09 08_04_48-TBA MDV - Power Apps.png

  • cchannon Profile Picture
    4,702 Super User 2025 Season 1 on at
    Re: Pass parent parameter to child related new form field

    @ScottDurow can easily correct me if I'm wrong on this one, but if you're using the Ribbon Workbench, you can pass the PrimaryControl to the javascript function in your call. This PrimaryControl object can be treated almost the same as executionContext in normal formscript. You just need to access it something like this:

    ribbonButton.execute = function (executionContext) {
     'use strict';
     let formContext = executionContext.ui.formContext;
     //do stuff
     });
    }

    This will give you a formContext object just the same as you'd get in normal formscripting.

    ---

    Now, all that said, I don't think you really need to do all that. Instead, I would recommend you consider using a QuickCreate form. These can be set up with no code at all and accomplish basically what you're looking for, they just use a side panel instead of a floating dialog.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 69 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 51 Super User 2025 Season 1

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 36

Overall leaderboard