Showing results for 
Search instead for 
Did you mean: 
Continued Contributor
Continued Contributor

Pass parent parameter to child related new form field

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,




Super User
Super User

@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.

Continued Contributor
Continued Contributor



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

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.

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.

Continued Contributor
Continued Contributor

@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


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


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,




Helpful resources

Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Users online (4,483)