Displaying the GUID of the record selected using the <CrmParameter> parameter and displaying the Current User’s GUID

One of my customers wanted to pass the GUID of the selected record(s) and the current user’s GUID in CRM’s grid view to a custom web page. CRM 2011 allows you to customize the Ribbon for both the Forms and Grid pages for an entity. To get the GUID of the record(s) selected in the Grid page of an entity we can use the <CrmParameter> tag. This TechNet article (http://technet.microsoft.com/en-us/library/gg309332.aspx) contains all the valid values for the <CrmParameter> tag.

To create custom buttons on the Grid page on an entity, following the instructions outlined in the Walkthrough: Add a Custom Group to an Existing Tab for a Specific Entity (http://msdn.microsoft.com/en-us/library/gg334578.aspx) article.

Follow the instructions below to display the GUIDs of all the records selected in the grid view of an entity (Button A), display the current user GUID (Button B), and display the CRM Organization Name (Button C).

1)      Create a Jscript Web Resource (e.g. sample_ShowValue) and add the following functions to display the message box –

The showvalue function uses the <CrmParameter> value as input values.

The showuserid function uses the Xrm.Page.context.getUserId() function to display the current user’s GUID.


2)      To display the GUIDs of the selected records, add the following <CrmParameter> tag with the value of SelectedControlSelectedItemIds to the </JavaScriptFunction> tag –


 3)      To display the user GUID, call the showuserid() function –


4)      To display the CRM Organization name, add the following <CrmParameter> tag with the value of OrgName to the </JavaScriptFunction> tag –

The appropriate data will be displayed in a Prompt box when the respective button is clicked.



Attached is the managed solution for the above code.


Comments (0)