Search code examples
javascriptdynamics-crmdynamics-crm-2016

openStdDlg returning null in Chrome


I have been using openStdDlg method for opening a Lookup view in Dynamics CRM. Problem is that this method returns null in Chrome when a user selects a record in the lookup and press OK but works normally in IE. I have Dynamics CRM 2016 On-premise v8.1.0.359.

return openStdDlg(oUrl, wndArgs, width, height, true);

Any tips / ideas how to get around this problem?


Solution

  • If you dig into the openStdDlg function you may find it leveraging showModalDialog (not sure it does) which was removed from Chrome a while back.

    An alternative unsupported way which should still work is Mscrm.CrmDialog. So you can try something like:

    var dialogWidth = 500;
    var dialogHeight = 500;
    //replace with your lookup dialog URL
    var lookupDialogUrl = Xrm.Page.context.getClientUrl() + "/_controls/lookup/lookupinfo.aspx?AllowFilterOff=0&...";
    var callbackRef = function(r){alert(r)};
    //instantiate dialog
    var dialogWindow = new window.top.Mscrm.CrmDialog(Mscrm.CrmUri.create(lookupDialogUrl), window, dialogWidth, dialogHeight);
    //set callback to execute when selection is made and dialog closes
    dialogWindow.setCallbackReference(callbackRef);
    dialogWindow.show();
    

    The above would launch a lookup dialog (once you fill in the rest of the lookup path) and then in your callback you can use the result from the lookup dialog for whatever you need.