"тнιѕ вℓσg ¢συℓ∂ ѕανє уσυя мσηєу ιƒ тιмє = мσηєу" - ∂.мαηנαℓу
Showing posts with label How to call a Dialog in CRM 2011 using Javascript. Show all posts
Showing posts with label How to call a Dialog in CRM 2011 using Javascript. Show all posts

Thursday, 7 July 2011

How to call a Dialog in CRM 2011 using Javascript

Let's see how to call a Dialog using Javascript in CRM 2011.
Firstly we need to find out the ID of the Dialog. This could be attained in 2 ways.

1. Search with Dialog name in Customizations.xml

For eg: If you search with your dialog name, you could find something similar to this.

<Workflow WorkflowId="{a13ad982-d812-40a0-ab67-f314cdabbd2b}" Name="MyDialog">
</Workflow>


2. Open the Dialog and press F11 to get the URL. In the URL we could find out the ID of the Dialog.


Javascript Code snippet:
var dialogId = "a13ad982-d812-40a0-ab67-f314cdabbd2b"; // This must be your Dialog ID
var returnValue = showModalDialog("/" + Xrm.Page.context.getOrgUniqueName() + "/cs/dialog/rundialog.aspx?DialogId=%7b" + dialogId + "%7d&EntityName=account&ObjectId=" + Xrm.Page.data.entity.getId());

//Optional:To save and close entity form as soon as the dialog is closed.
Xrm.Page.data.entity.save("saveandclose");


Sample Scenario  :
To open a Dialog when the user clicks on Ribbon button of the entity form.