Thursday, 3 September 2015

Open Dialog Box in CRM 2013/2015

Today we got a requirement to get the address from some external system and show them as popup to the user. User selects one of the addresses and we need to do some business operation based on the selection.
The challenge is to show the UI like CRM windows so that the user will not see any difference in the UI.
After some search came to know that we can do this using XRM Javascript and it is very simple too.
Create a HTML webresource and design it as per your requirement.
Make sure you include the reference of ClientGlobalContext.js.aspx in the webresource.

<script type="text/javascript" src="ClientGlobalContext.js.aspx"></script>

Call the web resource using the following code.

var vDialogOption = new Xrm.DialogOptions;
// Set height and width of the window
vDialogOption.width = 100; DialogOption.height = 100;
Xrm.Internal.openDialog("Relative_Url_of_the_Webresource", DialogOption, null, null, CallbackFunction);

On the button click, you can also return values from Popup.
//Pass the return Value to the parent window
Hope this helps
Happy CRM'ing

1 comment: