Enabling button in SubGrid on selection of record (SelectionCountRule) in CRM 2011


We had a requirement to have a custom button on a subgrid for an entity, and the button should only be enabled if and only if one record is selected.

It should get disabled in case if no records are selected or more than one record selected.

Used the below ribbondiffxml to achieve that

          <CustomAction Id="MyOrg.CustomAction" Location="Mscrm.SubGrid.entitySchemaName.MainTab.Management.Controls._children" Sequence="50">
              <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" />
          <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
          <CommandDefinition Id="MyOrg.Command">
              <EnableRule Id="MyOrg.EnableRule"></EnableRule>
             <DisplayRules />
              <JavaScriptFunction Library="$webresource:new_test" FunctionName="showvalue">
                <StringParameter Value="Guid(s) Selected"></StringParameter>
                <CrmParameter Value="SelectedControlSelectedItemIds"></CrmParameter>
          <TabDisplayRules />
          <DisplayRules />
            <EnableRule Id="MyOrg.EnableRule">
              <SelectionCountRule AppliesTo="SelectedEntity" Maximum="1" Minimum="1"></SelectionCountRule>
        <LocLabels />

Hope it helps



Author: Nishant Rana

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

One thought on “Enabling button in SubGrid on selection of record (SelectionCountRule) in CRM 2011”

Please 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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.