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.
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.
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.
This is my javascript to show the centered dialog
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 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
Opleiding
Relationship
I checked network traffic on clicking the default new extra kost button and this is what is passing:
The field i am trying to populate is (the training object i am adding a extra cost to): cref8_extrakosttraining
Best Regards,
Anthony
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.
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.
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.
@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.
WarrenBelz
69
Most Valuable Professional
mmbr1606
51
Super User 2025 Season 1
MS.Ragavendar
36