serving the solutions day and night

Pages

Friday, August 30, 2013

MS Dynamics CRM 2011 - EnableRule, ValueRule, OrRule & CustomRule in Ribbon Customizations

ValueRule - Enable the Custom button only when a specific filed on the form has a value.
For example, if the 'Email' field has value then the custom will be enable otherwise it will disable.

/RibbonDiffXml/RuleDefinitions/EnableRules/EnableRule/

<EnableRule Id="DNS.contact.form.EmailValue.EnableRule">
    <ValueRule Field="email" Value="null" InvertResult="true"/>
</EnableRule>

EnableRule for mulitple fields, use 'OrRule', for example

<EnableRule Id="DNS.contact.form.EmailValue.EnableRule">
    <OrRule>
        <Or>
            <ValueRule Field="email" Value="null" InvertResult="true"/>
        </Or>
        <Or>
              <ValueRule Field="leadsourcecode" Value="810520005"/>
        </Or>
    </OrRule>
</EnableRule>
           
EnableRule only works with Equal(=) condition, for different conditions (not equal) use 'InvertResult' attribute.

Refer the above id in the following location /RibbonDiffXml/CommandDefinitions/CommandDefinition/EnableRules

<EnableRule Id="Sample.account.form.CheckFaxValue.EnableRule"/>

CustomRule - call a javascript function based on the result.

<EnableRule Id="DNS.contact.form.EmailValue.EnableRule">
  <CustomRule FunctionName="DisableReportButton" Library="$webresource:dns_JavaScript/reports.js" Default="true" />
</EnableRule>

http://msdn.microsoft.com/en-us/library/gg334317.aspx
http://msdn.microsoft.com/en-us/library/gg328073.aspx
http://msdn.microsoft.com/en-us/library/gg309433.aspx

No comments: