Link to home
Start Free TrialLog in
Avatar of newjeep19
newjeep19Flag for United States of America

asked on

Open up a CRM 2011 Dialog using a JS button

I have a button on a CRM 2011 Entity that when clicked it should open a dialog. The issue is that the dialog is not opening. My java script code is below:
function Mscrm_Isv_quote_Form_Group1_Control6_0() {
    OpenLeadConvertDialog();--does not open the function
}


// DISABLE Approve 500k Quote BUTTON -- checks if the fields have the condtions...if so then the button is visable

function ButtonEnable_500kQuote() {
    var _stateCode = Xrm.Page.getAttribute("statecode").getValue();
    var _statuscode = Xrm.Page.getAttribute("statuscode").getValue();
    var _totalamount = Xrm.Page.getAttribute("totalamount").getValue();
    var _approved500k = Xrm.Page.getAttribute("gtri_totalamountapprovedover500").getValue();

    if (_stateCode != 1 || _statuscode == 3 || _totalamount == "undefined" || _totalamount < 500000) {
        return false;
    }
    else {
        if (_approved500k == "undefined" || _approved500k == 0) {
            return true;
        }
        else {
            return false;
        }
    }
}

//FUNCTION Call Dialog-- not working but should be opening or launching the dialog

function OpenLeadConvertDialog() {
    var _serverUrl = Xrm.Page.context.getServerUrl();
    var _dialogId = "ACE96291-2E9B-4B4E-83E5-BD4AAEB5A4F6";
    var DialogURL = _serverUrl + "/cs/dialog/rundialog.aspx?DialogId=%7b" + _dialogId + "7d&EntityName=quote&ObjectId" + Xrm.Page.data.entity.getId();
    var _sOptions = 'dialogWidth:500px; dialogHeight:400px';
    var _returnValue = showModalDialog(DialogURL, null, sOptions);

    if (DialogURL != "") {
        window.open(DialogURL);

    }
}

Open in new window


So, basically when the user clicks on the button (Mscrm_Isv_quote_Form_Group1_Control6_0) that should then call the (OpenLeadConvertDialog) function which builds the url to the dialog box.
Please help.
Thank you
ASKER CERTIFIED SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial