Friday 14 December 2012

Trigger dialog from ribbon button in crm 2011 using javascript


function calldialog(dialogId, entityName, recordId) {
    var url = Xrm.Page.context.getServerUrl();

    recordId = recordId.replace("{", "");
    recordId = recordId.replace("}", "");
    dialogId = dialogId.replace("{", "");
    dialogId = dialogId.replace("}", "");

    url += "/cs/dialog/rundialog.aspx?DialogId=%7b" + dialogId.toUpperCase() + "%7d&EntityName=" + entityName + "&ObjectId=%7b" + recordId + '%7d';

    window.showModalDialog(url);
}

Copy your dialog process Id:


  1. Click Settings-->Solutions-->Open your Solutions-->Process-->Open your dialog process
  2. Click Actions-->Copy a Link
  3. The Link contains the Id of this dialog process.



Create a new button using visual ribbon editor tool and pass the parameter as follows






Function Name:calldialog
Library: $webresource:<webresource name>
1. String parameter Value: < Id of dialog process to be launched>
2.String parameter Value: <Name of the entity where the dialog will be launched>
3.Crm parameter: FirstPrimaryItemId // Current record Id

No comments:

Post a Comment