jimminybob
jimminybob

Reputation: 1442

Custom Ribbon Button SelectionCount rule not always working

I have created a set of ribbon buttons on my CRM entity that use an enable rule so that they are available only when a single record in the view is selected, any more or less and the buttons should no longer be enabled.

This does work, but it has occasions where it won't what it is meant to. Sometimes I click into the view and select a field and the buttons remain disabled, or I click on several and they are still enabled.

Is this just a flaw in how they work or do I need to add something extra to ensure that they work every time?

Thanks

Upvotes: 1

Views: 2045

Answers (2)

Adel Šabić
Adel Šabić

Reputation: 1

I has been 8 years now, but someone could find this useful :)

Try adding distinct="true" to your view fetchxml

<fetchxml>
   <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true">
      <entity name="entity">
         <attribute name="attribute" />
      </entity>
   </fetch>
</fetchxml>

If you are using minimum=1 and maximum=1 in your SelectionCountRule then when records overflow to another page you may have some issues of SelectionCountRule being false even tho you selected certain record.

Upvotes: 0

lazarus
lazarus

Reputation: 2017

Enable rule for specific ribbon button should be like:

<EnableRules>
            <EnableRule Id="crm.Form.contact.MainTab.Collaborate.SendNotif.Command.EnableRule.OrRule">
              <OrRule>
                <Or>
                  <FormStateRule State="ReadOnly" />
                </Or>
                <Or>
                  <FormStateRule State="Existing" />
                </Or>
              </OrRule>
            </EnableRule>
            <EnableRule Id="crm.Form.contact.MainTab.Collaborate.SendNotif.Command.EnableRule.RecordPrivilegeRule">
              <RecordPrivilegeRule AppliesTo="PrimaryEntity" PrivilegeType="AppendTo" />
            </EnableRule>
            <EnableRule Id="crm.HomepageGrid.contact.MainTab.Collaborate.SendNotif.Command.EnableRule.SelectionCountRule">
              <SelectionCountRule AppliesTo="SelectedEntity" Maximum="1" Minimum="1" />
            </EnableRule>
          </EnableRules>

In sample above, main part is:

<EnableRule Id="crm.HomepageGrid.contact.MainTab.Collaborate.SendNotif.Command.EnableRule.SelectionCountRule">
      <SelectionCountRule AppliesTo="SelectedEntity" Maximum="1" Minimum="1" />
</EnableRule>

If you are using Visual Ribbon Editor for crm 2011 (I recommend) enable rule tab should be like:

enter image description here

Compare your settings with this example. This works, verified :)

Hope it helps

Upvotes: 1

Related Questions