Lets consider a scenario where we have a custom button on the Application ribbon and we would like to enable it only when the user selectes minumum 2 records. This requirement could be attained by using <EnableRules> in the customizations.xml.
Lets try by creating a New solution. For detailed steps please refer the first link.
Before exporting add the Application ribbon component to the Solution as shown below.
After this step, export the solution and then extract it to open the customizations.xml.
Lets modify the customizations.xml in such a way that we would place a button and that button will be enabled only when the user selects a minimum of 2 records.
EnableRule could be defined under the ruledefinitions tag as shown.
Here we have chosen one of the enable rules namely, SelectionCountRule. As the name indicates, this enables a button based on the count of the records selected. In this case we have defined the minimum as 2 and maximum as 50. The button will be enabled only if we choose at least 2 records.
<SelectionCountRule AppliesTo="SelectedEntity" Minimum="2" Maximum="50"></SelectionCountRule>
So when we import the customizations.xml, we would get a disabled button as shown below.
Please note 2 important points. 1. There is a button namely AlfaPeople on the Application ribbon but its disabled 2. There are no records chosen by the user.
So lets create 2 Account records and test the same. As you could see, the button gets enabled when we choose atleast 2 records. If you click on the button it will navigate to our company website.
<CustomAction Id="myAction" Sequence="41"
<Button Id="myButton" TemplateAlias="o1" LabelText="AlfaPeople" Command="sample.myCommand">
<SelectionCountRule AppliesTo="SelectedEntity" Minimum="2" Maximum="50">