Wednesday, September 12, 2012

CRM 2011 Ribbon Workbench - Getting guids from selected records in the grid

For those who need to make changes to the crm 2011 ribbon, I strongly suggest that you run, not walk, and download the ribbon workbench tool from Develop1. It is so far the best utility to make painless modifications to the CRM ribbon, and also has decent write ups and articles to cover most of your needs. In this post, I will walk though a setup which grabs the selected guids from a grid view, using a button created on the entity main page.

Business Case:
Create a button on the User entity page that displays the list of the user guids selected in the grid view.

I am going to leverage the Ribbon Workbench to create the button on the User grid. The "GetIds" button will call a html web resource which contains javascript to extract and display the user guids.

Implementation Details:
1. Before we start, let us first create the webresources that we will be using when creating the button. Create a 16x16 and 32x32 png image webresource to use as the button icon. Then create a html webresource with the following code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >


    <title>Untitled Page</title>

     <script type="text/javascript">

  document.onreadystatechange = function () {

   if (document.readyState == "complete") {




    function GetSelectedIds() {

        var vals = new Array();

        if ( != "") {

        vals = decodeURIComponent("=");

        var selectedIds = vals[1].toString().split(',');









2. Open the ribbon workbench and select the solution. Stay on the "HomePage" (the dropdown on the top right corner) and select the user entity.

3. Drag and drop the Button from the left navigation Toolbox section to the desired location.

4. Right Click "Commands" in the Solution Elements box. Create a new command. Under Properties: Command Definition, section "Misc", click on the Action lookup icon.

5. Add an "Open Url Action". Set address value to "$webresource:<htm resource name>". Add a parameter of type "CRM parameter" with the following values: Name: "data", Value: "SelectedControlSelectedItemsIds"

6. Select the command definition created from the ButtonControl properties Command drop down. This way we associate the action of opening the html webresource to the button on click event.

Here is what the Solution Elements section looks like after the changes:

Here are the properties of the command action:

Here are the CRM parameter properties:

And finally, the ButtonControl properties:

Once the setup is similar to the above screenshots, publish the changes to the crm server. Go to the User grid, select a few of the records and click on the "Get Ids" button on the ribbon. You will see a webpage with a javascript alert like the one below:

No comments:

Post a Comment