Monday, May 9, 2011

Hiding Ribbon Button in CRM 2011

Hi All, Here i am going to hide a ribbon button from account entity at form level and home page grid level.

Before Hiding Button from the Account Home page Grid
After Hiding the Button from the Account Home page Grid
Before Hiding button from the Account Form
After Hiding button from the Account Form

Follow the following steps to hide the button from the account entity

1. We needs to find the Id of the button " Add to Marketing List", which we wants to hide. To find the Id of this button go to the CRM Sdk, and find the "accountribbon.xml" file at "sdk\samplecode\cs\client\ribbon\exportribbonxml\exportedribbonxml". Open "accountribbon.xml" file and find the Id of the button which we wants to hide. 
  For "Add to Marketing List" button Id at Home page grid level is "Mscrm.HomepageGrid.account.AddToList"
 For "Add to Marketing List" button Id at Form level is "Mscrm.Form.account.AddToList"
2. Now Export the solution and open the "Customization.xml" file for editing.
3. Find the <RibbonDiffXml> tag at Account entity level, add the following code

Here is the code to copy
<RibbonDiffXml>
 <CustomActions>
 <!-- Hide "Add to Marketing List" button at grid level, here Location will be the button id and HideActionId will be any unique id-->
 <HideCustomAction Location="Mscrm.HomepageGrid.account.AddToList" HideActionId="Sample.HomepageGrid.account.HideMarketingList"/>
 <!-- Hide "Add to Marketing List" button at Form level-->
 <HideCustomAction Location="Mscrm.Form.account.AddToList" HideActionId="Sample.Form.account.HideMarketingList"/>
 </CustomActions>
        <Templates>
          <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
        </Templates>
        <CommandDefinitions />
        <RuleDefinitions>
          <TabDisplayRules />
          <DisplayRules />
          <EnableRules />
        </RuleDefinitions>
        <LocLabels />
      </RibbonDiffXml>

4. Now import the solution back into CRM. You can find the changes.

Thats it.. It's very simple to hide a button in crm2011. we can also use Display rules to hide the buttons. Based on the user security permission we can show the buttons using display rules.




5 comments:

  1. Hello,

    I want to hide the button but conditionally based on the field value. How can i do that?

    Thanks in Advance

    ReplyDelete
    Replies
    1. Take a Look into this article, I always trust PowerObject people.

      http://www.powerobjects.com/blog/2011/06/17/crm-2011-enabling-and-disabling-ribbon-buttons-2/

      I had the same requirement and this article was perfect helpful.

      Let me know if it helpful or i can help you.

      Delete
  2. Hi Rajesh,

    Use the Custom Rules to hide Ribbon buttons conditionally. check this MSDN article to use Custom Rule.

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

    ReplyDelete
  3. Hello,
    Here its maintined customRule. I have also used custom rule but my custom rule function is not called.






























    Please help me on this

    Thanks in Advance

    ReplyDelete
  4. Hi rajesh,

    sorry for the late reply.. i was busy..

    http://msdn.microsoft.com/en-us/library/gg334209.aspx

    use this article, use value rule of display rule to conditionally hide the button..

    ReplyDelete