1
votes

In my lead home page, there is a custom button. The enable rule for that button is:

<EnableRule Id="enableruleid">
   <SelectionCountRule AppliesTo="SelectedEntity" Minimum="1" Maximum="1"></SelectionCountRule>
   <CustomRule FunctionName="functionname" Library="$Webresource:myjavascript.js">
           <CrmParameter Value="SelectedControlSelectedItemIds" />
    </CustomRule>
 </EnableRule>

The javascript working fine only for the first time select a record, when you select another record, the javascript doesn't called.

For example, I select record A, the button is enabled and it's fine; and then I select record B, the button should be disabled, but it's not, it still enabled.

But if I select record B first, the ribbon is disabled as I wish, and then I select record A, the button still disabled.

Anyone know why it like this?
Any suggestions?

Update: If I select multiple records, and then un-select most of them only left one, the enable rule works. Or I select one record --> un-select it --> select another record, it also works. The problem only occurs when I directly click on the "row" instead of the checkbox.

1
What is the JavaScript doing?James Wood
Hi @JamesWood, the javascript only do one thing, check the record's statecode and return true of false.nixjojo
Can you please be more specific about what the enable rule should do, e.g. what is the requirement?James Wood
Requirement is - if record's statecode is 0, enable the button; else disable the button.nixjojo

1 Answers

2
votes

Well your rule states that a minimum of 1 record must be selected, so, selecting one record or more records would seem to qualify for leaving the button enabled.

Perhaps you should also include a maximum?

SelectionCountRule (RibbonDiffXml)