none
[CRM 2013] - Open a dialog box via custom button with showModalDialog result in pop-up error

    Question

  • Hi,

    We currently use a custom ribbon button named "Créer un dossier" that permit to open a existing dialog box in a new window.

    In this dialog box contain some fields to fill. When all field are filled, i click in the "next" button and "Finish" but after clicking in "finish" button, i get this pop up error (screen below).

    I use "showModalDialog" function to open the dialog box in a new window. So i know that it's unsupported development but i don't know how i can open a new window exactly like a modal window and not a tab.

    If anyone knows the solution, please tell me.

    Thanks for your help.

    regards,

    Jean-Michel

    Wednesday, March 05, 2014 10:17 AM

Answers

  • Hi, 

    The problem have been resolved by replacing "showModalDialog" wich is not supported (below):

    window.showModalDialog(mypath, '', 'unadorned:yes; dialogWidth:800px; dialogHeight:600px; center:yes ; resizable:no;');

    To an "openStdDlg" (below):

    openStdDlg(mypath, '', 800, 600, false);

    Regards,

    • Marked as answer by DOS-SANTOS Tuesday, March 18, 2014 2:36 PM
    Tuesday, March 18, 2014 2:36 PM

All replies

  • Hi Jean,

    Use the following code for Opening Custom Dialog on Custom Button Click .It is for CRM 2013 and showModalDialog() will not support CRM 2013. So use the follwoing function to call dialog on button click . it will work .

    function ExecuteDialog() {
        var DialogId = "9817F404-5985-451F-8D4C-2309B7F7E1E9";
        var url = Xrm.Page.context.getClientUrl() + "/cs/dialog/rundialog.aspx?DialogId=%7b" + DialogId + "%7d&EntityName=contact&ObjectId=" + Xrm.Page.data.entity.getId();

        window.open(url, null);
    }


    K V SambasivaRao

    Thursday, March 06, 2014 4:46 AM
  • Hi,

    Thanks for your help Gopinath but this blog is for CRM 2011. In the CRM 2013, showModalDialog is not supported, so that's why i get the error. 

    Thanks SambasivaRao, the code you gave me work well but this is not possible with a "Window.open" to open the window in a new window resized and not in a new tab ? 

    Here's the code i have now : 

    // Lancement de la boîte de dialogue de création d'un nouveau dossier
    function CreationDossier(typeName, recordId) {
        // On récupère le nom de l'entité et l'url
        var entityName = Xrm.Page.data.entity.getEntityName();
        var serverUrl = Xrm.Page.context.getServerUrl();
    
        // DEMANDE MEDIATION
        if (entityName == "neos_demande_mediation") {
    
            // Id de la boîte de dialogue
            dialogId = "{E4BBE996-2EC1-49A8-B930-84A2DF8F355A}";
    
            // La boite de dialogue de création de dossier ne se lance que si le champ "Dossier à créer" est coché.
            recordId = recordId.replace("{", "");
            recordId = recordId.replace("}", "");
            dialogId = dialogId.replace("{", "");
            dialogId = dialogId.replace("}", "");
            // Load modal  
            var serverUri = serverUrl + '/cs/dialog/rundialog.aspx';
            var mypath = serverUri + '?DialogId=%7b' + dialogId.toUpperCase() + '%7d&EntityName=' + typeName + '&ObjectId=%7b' + recordId + '%7d';
            // First item from selected contacts only  
            // window.showModalDialog(mypath, '', 'unadorned:yes; dialogWidth:800px; dialogHeight:600px; center:yes ; resizable:no;');
            window.open(mypath, null);
            // Refresh datas.  
            Xrm.Page.data.refresh();
    
        }
    

    If anyone knows how to open a new window resized by using another way than "ShowModalDialog".

    Thanks for your help again. 

    Regards,

    Jean-Michel

    Monday, March 10, 2014 10:40 AM
  • Hi, 

    The problem have been resolved by replacing "showModalDialog" wich is not supported (below):

    window.showModalDialog(mypath, '', 'unadorned:yes; dialogWidth:800px; dialogHeight:600px; center:yes ; resizable:no;');

    To an "openStdDlg" (below):

    openStdDlg(mypath, '', 800, 600, false);

    Regards,

    • Marked as answer by DOS-SANTOS Tuesday, March 18, 2014 2:36 PM
    Tuesday, March 18, 2014 2:36 PM