Hi Pete,
You can call this JavaScript function on Change event. This code will also make sure that it will work only if there is any value inside the LookupField.
function LookUpChange (executionContext) {
'use strict';
var formContext = executionContext.getFormContext();
var LookupField = formContext.getAttribute("TargetedLookupFieldName").getValue();
if(LookupField){
console.log("Function is loaded");
var qs = "param1=1¶m2=2";
var pageInput = {
pageType: "webresource",
webresourceName: "WebResourceName",
data: encodeURIComponent(qs)
};
console.log(pageInput.webresourceName);
var navigationOptions = {
target: 2,
width: 400,
height: 300,
position: 1
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
function success() {
debugger;
},
function error(e) {
}
);
}
}
To register this event, open the form properties add the web resource to the event library and then add this event handler to the field on change event. Here is an example of how I did it:
I hope this will help. Feel free to ask me if you have any questions/concerns. Also please mark my answer as Best Answer if this is helpful.
Thanks
Jay
------------------------------
JayBuddhdev
https://www.powerappsd365.comRegina SK Canada
------------------------------
Original Message:
Sent: Feb 21, 2020 10:08 AM
From: Pete Axtell
Subject: Modal Forms with Release Wave 1
Have avoided using javascript where possible but this sounds like it might be useful. How is this script bound to individual lookup fields?
------------------------------
Pete Axtell
Winton
Original Message:
Sent: Feb 20, 2020 09:35 AM
From: Jay Buddhdev
Subject: Modal Forms with Release Wave 1
Hi Erik,
Yes I have tried this new navigateTo API and it seems to be working fine. Here is the sample code that I have used:
var qs = "param1=1¶m2=2";
var pageInput = {
pageType: "webresource",
webresourceName: "NameOfWebResource",
data: encodeURIComponent(qs)
};
var navigationOptions = {
target: 2,
width: 400,
height: 300,
position: 1
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
function success() {
debugger;
},
function error(e) {
}
);
If you are looking to implement it in the side pane (like QuickCreate) just change the position from 1 to 2:
var qs = "param1=1¶m2=2";
var pageInput = {
pageType: "webresource",
webresourceName: "NameOfWebResource",
data: encodeURIComponent(qs)
};
var navigationOptions = {
target: 2, // 2 is for opening the page as a dialog.
width: 400, // default is px. can be specified in % as well.
height: 300, // default is px. can be specified in % as well.
position: 2 // 2 to open the dialog on the side. Default is 1 (center).
};
Xrm.Navigation.navigateTo(pageInput, navigationOptions).then(
function success() {
debugger;
},
function error(e) {
// Handle errors
}
);
Code Reference: https://debajmecrm.com/2019/11/27/open-webresources-modal-or-inline-using-xrm-naviagtion-naviagteto-in-dynamics-365-unified-interface/
Please let me know if you have any questions/concerns.
Thanks
Jay
------------------------------
JayBuddhdev
https://www.powerappsd365.com
Regina SK Canada
Original Message:
Sent: Feb 20, 2020 09:04 AM
From: Erik Seitz
Subject: Modal Forms with Release Wave 1
Hello Everyone!
I was wondering if anyone has had any luck implementing the navigateTo API call for modal forms yet? I have a use case where this functionality would be great but am not exactly sure on how to properly trigger the event. I am hoping that i can add this functionality to when a user clicks "new" in a subgrid or double clicks an existing record in the subgrid. From my understanding of the documentation this should be possible but im not sure how to get the onclick registered from a native button on the subgrid...
Thanks for any help or direction!
------------------------------
Erik Seitz
RJ Corman Railroad Group, LLC
Nicholasville KY
------------------------------