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 / Pass parent parameter ...
Power Apps
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

 

 

I have the same question (0)
  • cchannon Profile Picture
    4,702 Moderator on at

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

  • AnthonyD Profile Picture
    559 on at

    @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 Moderator on at

    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.

  • skoofy5 Profile Picture
    482 on at

    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.

  • AnthonyD Profile Picture
    559 on at

    @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

     

     

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 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard