Sample Code for adding a button for SubGrid and passing id of the selected records (CRM 2011)

Simply replace the entity schema name with your entity

  <RibbonDiffXml>
        <CustomActions>
          <CustomAction Id="MyOrg.CustomAction" Location="Mscrm.SubGrid.entitySchemaName.MainTab.Management.Controls._children" Sequence="50">
            <CommandUIDefinition>
              <Button Id="MyOrg.Button" ToolTipTitle="Upload Required Document" ToolTipDescription="Upload Required Documents for the Case" Command="MyOrg.Command" Sequence="50" LabelText="Upload Document" Alt="Upload Document To Portal" Image16by16="/_imgs/ribbon/AddEmail_16.png" Image32by32="/_imgs/ribbon/Email_32.png" TemplateAlias="o1" />
            </CommandUIDefinition>
          </CustomAction>
        </CustomActions>
        <Templates>
          <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
        </Templates>
        <CommandDefinitions>
          <CommandDefinition Id="MyOrg.Command">
            <EnableRules />
            <DisplayRules />
            <Actions>
              <JavaScriptFunction Library="$webresource:new_test" FunctionName="showvalue">
                <StringParameter Value="Guid(s) Selected" > </StringParameter>
                <CrmParameter Value="SelectedControlSelectedItemIds"></CrmParameter>
              </JavaScriptFunction>
            </Actions>
          </CommandDefinition>
        </CommandDefinitions>
        <RuleDefinitions>
          <TabDisplayRules>
          </TabDisplayRules>
          <DisplayRules />
          <EnableRules />
        </RuleDefinitions>
        <LocLabels />
      </RibbonDiffXml>

Function for the jscript web resource.

function showvalue(){

alert(value);

}

Hope it helps.


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

1 thought on “Sample Code for adding a button for SubGrid and passing id of the selected records (CRM 2011)”

  1. Can you explain “Simply replace the entity schema name with your entity” and second was this so you could upload a file to SharePoint? If so can you share that code? Thanks!!

    Like

Share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s