CRM 2011 – Launch a Dialog Window from JavaScript

// Launches a Dialog Popup
function LaunchDialog(organizationName, dialogId, objectId)
{
	if(organizationName != null && dialogId != null && objectId != null)
	{
		var url = "http://" + window.location.host + "/" + organizationName + "/cs/dialog/rundialog.aspx?DialogId=" + dialogId + "&EntityName=task&ObjectId=" + objectId;

		window.open(url, "AutomaticDialog", "status=0,toolbar=0,scrollbars=0");
	}
}
}

7 comments

  1. Hi,
    useful article, is it possible use the same logic to open custom report for a selected record? I need to use fiddler to capture custom report url?
    thanks

  2. What is used in for the objectId? Is the the guid of the entity of the dialog and if so how to pass it( “{xxxxxxxx-…-xxxxx}” or “xxxxxxxx-…-xxxxx”) in the parameter?

  3. Hello TK,

    The objectId represents the CRM record Guid. To get this id, you can use:

    Xrm.Page.data.entity.getId() – for CRM 2011
    or
    crmForm.ObjectId – for CRM 4.0.

    Both ids (dialogId, objectId) can be passed in both styles (with or without the “{” “}”)

    1. Hello,

      Can you explain why the objectid is required? I am creating something similar to your example however I’m not sure what to pass as the objectid. When I open the dialog and press F11 to be able to see the URL I notice that the objectid is always the same irrespective of from which record I initiate the dialog.

      I would be really greatful if anyone could help me.

Leave a Reply to professional tree service Cancel reply

Your email address will not be published. Required fields are marked *