Conditionally Hiding OOB Ribbon Button in CRM 2011

Written by admin. Posted in CRM TUTORIAL

Tagged: , , , , , , , , , ,

Published on October 05, 2013 with No Comments

Hi All, To hide the OOB Ribbon button permanently you can use my earlier post. But sometimes we needs to hide OOB Ribbon button conditionally in CRM 2011. Here I am going to hide OOB “Assign” button conditionally based on Optionset Value.

On the Account form, if the “Category” optionset value is “Preferred Customer” then display the “Assign” button otherwise hide the “Assign” button.

1. Export the solution and open Customization.XML file in edit mode. Find the <RibbonDiffXml> at the Account form level.


2. Now open Accountribbon.xml file from the SDK and find the Assign button details at form Level

Now copy the Assign button element from here and add this to custom Actions in the <RibbonDiffXML> which we are customizing.
we also needs to copy the CommandDefinition of the OOB Assign button to provide OOB assign functionality. otherwise OOB Asign button functionality might not work.
3. Now edit the Account <RibbonDiffXML> in the following way

<code> &lt;RibbonDiffXml&gt;<br />        &lt;CustomActions&gt;<br />          &lt;!-- Location will be ID of the Button--&gt;<br />          &lt;CustomAction Location="Mscrm.Form.account.Assign" Id="Sample.Form.account.HideAssign"&gt;<br />            &lt;CommandUIDefinition&gt;<br />              &lt;!-- copy the OOB Asign button CommandUI Definition--&gt;<br />              &lt;Button Id="Mscrm.Form.account.Assign" ToolTipTitle="$Resources:Ribbon.HomepageGrid.MainTab.Actions.Assign" ToolTipDescription="$Resources(EntityPluralDisplayName):Ribbon.Tooltip.Assign" Command="Mscrm.AssignPrimaryRecord" Sequence="33" LabelText="$Resources:Ribbon.HomepageGrid.MainTab.Actions.Assign" Alt="$Resources:Ribbon.HomepageGrid.MainTab.Actions.Assign" Image16by16="/_imgs/ribbon/Assign_16.png" Image32by32="/_imgs/ribbon/Assign_32.png" TemplateAlias="o1" /&gt;<br />            &lt;/CommandUIDefinition&gt;<br />          &lt;/CustomAction&gt;<br />        &lt;/CustomActions&gt;<br />        &lt;Templates&gt;<br />          &lt;RibbonTemplates Id="Mscrm.Templates"&gt;&lt;/RibbonTemplates&gt;<br />        &lt;/Templates&gt;<br />        &lt;CommandDefinitions&gt;<br />          &lt;!-- copy the OOB Asign button Command Definition--&gt;<br />          &lt;CommandDefinition Id="Mscrm.AssignPrimaryRecord"&gt;<br />            &lt;EnableRules&gt;<br />              &lt;EnableRule Id="Mscrm.FormStateNotNew" /&gt;<br />              &lt;EnableRule Id="Mscrm.AssignPrimaryPermission" /&gt;<br />              &lt;EnableRule Id="Mscrm.NotOffline" /&gt;<br />            &lt;/EnableRules&gt;<br />            &lt;DisplayRules&gt;<br />              &lt;DisplayRule Id="Mscrm.AssignPrimaryPermission" /&gt;<br />              &lt;DisplayRule Id="Mscrm.NotClosedActivity" /&gt;<br />              &lt;!-- Add new display Rule for conditionally hiding--&gt;<br />              &lt;DisplayRule Id="Sample.Form.account.HideAssign.DisplayRule"/&gt;<br />            &lt;/DisplayRules&gt;<br />            &lt;Actions&gt;<br />              &lt;JavaScriptFunction FunctionName="assignObject" Library="/_static/_forms/form.js"&gt;<br />                &lt;CrmParameter Value="PrimaryEntityTypeCode" /&gt;<br />              &lt;/JavaScriptFunction&gt;<br />            &lt;/Actions&gt;<br />          &lt;/CommandDefinition&gt;<br />        &lt;/CommandDefinitions&gt;<br />        &lt;RuleDefinitions&gt;<br />          &lt;TabDisplayRules /&gt;<br />          &lt;DisplayRules&gt;<br />            &lt;!--Define the conditional Hiding Display Rule--&gt;<br />            &lt;DisplayRule Id="Sample.Form.account.HideAssign.DisplayRule"&gt;              <br />              &lt;ValueRule Field="accountcategorycode" Value="1"/&gt;<br />              &lt;!--Field will be CRM field schema Name, Value will be optionset Value--&gt;<br />            &lt;/DisplayRule&gt;<br />          &lt;/DisplayRules&gt;<br />          &lt;EnableRules /&gt;<br />        &lt;/RuleDefinitions&gt;<br />        &lt;LocLabels /&gt;<br />      &lt;/RibbonDiffXml&gt;<br /> <br /></code>

4. Now import the customization file.

Hope it helps!!!

Just to Share My Knowledge on Microsoft Dynamics CRM…

No Comments

Comments for Conditionally Hiding OOB Ribbon Button in CRM 2011 are now closed.