Does anyone have a javascript code that opens an HTML webresource from the ribbon and return value to calling script?
The method should support all browsers
*This post is locked for comments
Does anyone have a javascript code that opens an HTML webresource from the ribbon and return value to calling script?
The method should support all browsers
*This post is locked for comments
For information, Microsoft will reject you to publish your code if you will use xrm.internal.opendialog().
They want we to use openWebResource()
This is the newest information from Microsoft (today's morning)
Also you can write unsupported way -
function (url, title) {
var w = screen.width - 75;
var h = screen.height - 200;
var left = (screen.width / 2) - (w / 2);
var top = (screen.height / 2) - (h / 2);
var newWindow = window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);
if (window.focus) {
newWindow.focus();
}
Hope this helps
You can get help from below link.
msdn.microsoft.com/.../jj602956.aspx;MSPPError=-2147217396
Thank you for the advise. I know it is unsupported. But it works with all browsers especially if u want to return values from the web resource. I prefer to take the risk rather than using a method that doesn’t work.
Hi Chadi,
Just for your information, Xrm.Internal,OpenDialog is an unsupported way of opening a dialog. It is an internal function by Microsoft, and can be changed at any time without notification.
You should try Xrm.Utility.openWebResource instead...
Thank you for the help but I ended up using xrm.internal.opendialog
Hi,
I'm not sure but you may give a try to the below code.
/* Function to open the window and attach the event */
function OpenWindowWithCallback() {
//pass the parameters and open the dialog
var win = window.open("yourcustomepageurl", null, "width=XX,height=XX,left=XX,top=XX,scrollbars=no");
//attach the event
if (typeof win.attachEvent != "undefined") {
win.attachEvent("onbeforeunload", Callback);
} else if (typeof win.addEventListener != "undefined") {
win.addEventListener("beforeunload", Callback, false);
}
}
/* Callback function */
Callback= function () {
//your custom code goes here
}
Let me know if it works.
Many thanks,
Nitin Verma
Hi Chadi,
I don't have the exact code you are looking for but it seems straight forward. There is a method in Xrm Utility to open web resource.
msdn.microsoft.com/.../jj602956.aspx
Hope this helps.
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,430
Most Valuable Professional
nmaenpaa
101,156