Configure ISV.Config
This example will configure a button on the Account entity grid. There are three steps to this process:
- Export ISV.Config
- Configure the button for the Account entity grid
- Import ISV.Config.
- In the Microsoft Dynamics CRM Web application, click Settings.
- Click Customization and then Export Customizations.
- Scroll down the list of Exportable items and select ISV.Config.
- Click Export Selected Customizations.
- Save the customizations.zip file.
- Extract the customizations.xml file from the customizations.zip file.
- Open the customizations.xml file using Visual Studio or any text editor, such as notepad.
- The default ISV.Config includes a number of sample extension control configurations. You can modify one of the existing extension controls or configure a new one.
- Locate the following node in the default ISV.Config:
ImportExportXml/IsvConfig/configuration/Entities/Entity name="account"/Grid/MenuBar/Buttons
- Configure a button element as a child of the Buttons element using this XML:
2. <Button
3. Icon="/_imgs/ico_18_debug.gif"
4. Url="/ISV/test.htm"
5. WinMode="2"
6. >
7. <Titles>
8. <Title LCID="1033" Text="Get GUIDS" />
9. </Titles>
10. <ToolTips>
11. <ToolTip LCID="1033" Text="Get GUIDS for selected records" />
</ToolTips>
</Button>
The key elements are the Url and WinMode attributes to the Button element. The URL must point to a page on the same domain as the Microsoft Dynamics CRM Server. This example will place the test.htm page in the ISV directory located in the Microsoft Dynamics CRM web site installation path. The WinMode attribute must be set to either 1 or 2 so that a dialog window is opened rather than a standard window. Window.dialogarguments is only available for the two dialog windows (modal and modeless).
- Save customization.xml file with the changes you have made.
- In the Microsoft Dynamics CRM Web application, click Settings.
- Click Customization and then Import Customizations.
- Browse to the customization.xml file you have saved and click Upload.
- After the file has loaded, click Import Selected Customizations.
Create the HTML Page to Capture the GUIDs
This page will use a JScript function in the onload event of the page to detect whether the window.dialogarguments is available and simply display the GUID values in the page. In a solution that would take actions using the GUID values, these values would typically be passed to another application.
- Create a file named test.htm in the ISV folder of your Microsoft Dynamics CRM Web application.
- Use the following code in the page:
3. <html>
4. <head>
5. <title>GUIDs for records seleced in Grid</title>
6. <script type="text/jscript">
7. function listselecteditems()
8. {
9. var placeholder = document.getElementById("test");
10. var sGUIDValues = "";
11. var selectedValues;
12. //Make sure window.dialogArguments is available.
13. if (window.dialogArguments)
14. {
15. selectedValues = new Array(window.dialogArguments.length -1);
16. }
17. else
18. {
19. placeholder.innerText = "window.dialogArguments is not available.";
20. return
21. }
22. selectedValues = window.dialogArguments;
23. if (selectedValues != null)
24. {
25. for (i=0; i < selectedValues.length; i++)
26. {
27. sGUIDValues += selectedValues[i] +"\n";
28. }
29. placeholder.innerText = sGUIDValues;
30. }
31. else
32. {
33. placeholder.innerText = "No records were selected.";
34. }
35. }
36. </script>
37. </head>
38. <body onload="listselecteditems()">
39. <div id="test"></div>
40. </body>
</html>
The listselecteditems function is called when the page loads. If window.dialogArguments doesn't exist, the innerText property of a placeholder div element in the pages is updated with a message. If window.dialogArguments does exist, a new array is created based on the length of window.dialogArguments. Then a for loop interates through the items in the array and the GUID values are appended to a string. The innerText value of the placeholder div element is updated with the string value.
Save the test.htm page to the ISV folder.
Test the Button
- In the Microsoft Dynamics CRM Web application, click Workplace.
- Click Accounts.
You should see the button you configured in the toolbar.
- Select a number of accounts in the view and then click the Get Guids button. The test.htm page should open and display the GUIDs for the selected accounts.