- In this walkthrough we will learn how to open a Dialog automatically from Client Side, using Javascript and a Web Resource, in Dynamics CRM 2011. A Web Resource is just a virtual file containing html, jscript, css, a picture or Silverlight , stored in the CRM database, and identified by a unique URL. After its creation, a Web Resource can be used in several CRM Forms, enhancing its functionality and appeareance. In our example, we will use a javascript Web Resource to launch a Dialog when an CRM Form opens:
- First, we'll need a javascript code inside a Web Resource. Open the Web Resources:
- ... and create a New Web Resource:
- Give it a Display Name with a "_" to make the Web Resource appear at the top of the Web Resources list, and set the Type to script:
- Open the Text Editor and type the javascript function that will open the Dialog:
The first parameter represents the CRM context, and the second will be the ID of the CRM Dialog we want to launch from the form. - Let's stop the creation of the Web Resource for now, and go to the form of the entity you want to open the dialog from:
- To relate our Web Resource to the form, open the Form Properties:
- Add the Web Resource to the Form Libraries:
- Find and open the Web Resource we just created:
- Next, add it as the Event Handler script that will run on a "OnLoad" event:
- The next step is to set what will be the function that will be called. Be careful to type exactly the same name you saved when you created the Web Resource:
Also, pass the execution context as the function's first parameter. - Now we have a little problem: the second parameter must be the ID of the Dialog we want to open. Where we can obtain the GUID of the Dialog? Well, that's a bit tricky. Go to the Dialog you want to launch:
- Open it, and click "Copy a Link" from the Actions menu:
That will copy to the clipboard a URL containing the GUID of the Dialog. - Go back to the Event Handler , and paste it to the parameters text box:
- You can see a URL and an "ID" in it: this is the GUID of the Dialog:
- So erase everything else , and close the GUID with quotes:
- Save the form and Publish it. Now we have the parameters we need . Get back to the Web Resource, and type the following code to get the Organization's server URL:
- Next, we need to determine the Entity Name and the ID of the Record represented by the CRM Form, so type the following code:
- Now we build the URL of the window that will open the dialog. Start with the server:
- ... and link the Entity Name and ID to the URL:
- Finally , type the javascript code that opens the window dialog:
- And we're done... Let's see how it works: open some Contact:
- ... And you'll see that the selected CRM 2011 Dialog launchs automatically when the Form opens:
That's all...Enjoy Dynamics CRM!!!כתב: כרמל שוורצמן
A Step-By-Step Walk-Through CRM 2011 designed for Begginer and Professional CRM Developers
Microsoft Dynamics CRM 2011
Tuesday, October 15, 2013
Step-By-Step How to open a Dialog from Client Side using Javascript
by Carmel Schvartzman
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment