cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anthony_Dob
Continued Contributor
Continued Contributor

Model Driven App Javascript to open form in modal centered dialog

Hi guys,

 

I have a Subgrid in a form that shows related data. I changed the subgrid to editable so i can add events to it. I added a "OnRecordSelect" event that should open the record i selected in a centered dialog instead of navigating to a full page.

 

As you can see the javascript is giving me errors and the Identifier i am passing is causing this to happen.

2021-12-08 11_43_10-TBA MDV - Power Apps.png

 

This is my javascript i am using to open the record as a centered dialog. As you can see the entityId is "Name".

2021-12-08 11_44_57-Form_ Opleiding.png

 

If we then check the table, we can see that the identifier is the column "Name"

2021-12-08 11_45_41-Power Apps _ Solutions - TBA Model Driven.png

 

A sidenote: I am using this exact same jscript function on another table and it works fine. The difference is that in that case the Primary name column of the table is called Id and it stores a auto generated Id.

 

Anyone who knows how to make this work?

 

Best Regards,

Anthony

1 ACCEPTED SOLUTION

Accepted Solutions
Anthony_Dob
Continued Contributor
Continued Contributor

So i just figured out EntityId should be Id..

function RunOnSelected(executionContext) {
var selected = executionContext.getFormContext().data.entity;
var Id = selected.getId();
 
var pageInput = {
pageType: "entityrecord",
entityName: "cref8_extrakost",
entityId: Id
};
var navigationOptions = {
target: 2,
height: {value: 50, unit:"%"},
width: {value: 50, unit:"%"},
position: 1
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
function success() {},
function error() {}
);
}

 

View solution in original post

1 REPLY 1
Anthony_Dob
Continued Contributor
Continued Contributor

So i just figured out EntityId should be Id..

function RunOnSelected(executionContext) {
var selected = executionContext.getFormContext().data.entity;
var Id = selected.getId();
 
var pageInput = {
pageType: "entityrecord",
entityName: "cref8_extrakost",
entityId: Id
};
var navigationOptions = {
target: 2,
height: {value: 50, unit:"%"},
width: {value: 50, unit:"%"},
position: 1
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
function success() {},
function error() {}
);
}

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,449)