Removing a ribbon button in CRM 2011

I needed to remove the Save and Close button from the Case entity when the form is in Create mode.

1) Find the Id of the button we are interested in.

Look at the output from the “ribbon” project of the CRM 2011 SDK. Within incidentribbon.xml we find:-

<Button
  Id="Mscrm.Form.incident.SaveAndClose"
  ToolTipTitle="$Resources:Mscrm_Form_Other_MainTab_Save_SaveAndClose_ToolTipTitle"
  ToolTipDescription="$Resources(EntityDisplayName):Ribbon.Tooltip.SaveAndClose"
  Command="Mscrm.SaveAndClosePrimary"
  Sequence="30"
  LabelText="$Resources:Ribbon.Form.MainTab.Save.SaveAndClose"
  Alt="$Resources:Ribbon.Form.MainTab.Save.SaveAndClose"
  Image16by16="/_imgs/FormEditorRibbon/SaveAndClose_16.png"
  Image32by32="/_imgs/ribbon/SaveAndClose_32.png"
  TemplateAlias="o1" />

We are interested in the Command value (Mscrm.SaveAndClosePrimary).

2) Export the entity as part of a blank solution. Open the corresponding customizations.xml and find the RibbonDiffXml section.

Expand the CommandDefinitions section and create new entries within it, using the Command value as follows:-

Before:

<CommandDefinitions />

After:

<CommandDefinitions>
<CommandDefinition Id="<strong>Mscrm.SaveAndClosePrimary</strong>">
<EnableRules>
<EnableRule Id="<strong>Mscrm.SaveAndClosePrimary</strong>.EnableRule" />
</EnableRules>
<DisplayRules>
<DisplayRule Id="<strong>Mscrm.SaveAndClosePrimary</strong>.DisplayRule" />
</DisplayRules>
    <Actions>
      <JavaScriptFunction FunctionName="Mscrm.RibbonActions.saveAndCloseForm" Library="/_static/_common/scripts/RibbonActions.js">
        <CrmParameter Value="PrimaryControl" />
      </JavaScriptFunction>
    </Actions>
</CommandDefinition>
</CommandDefinitions>

Copy the Actions section direct from the original file.

3) We now have two new rules (.EnableRule and .DisplayRule) which need to be defined within RuleDefinitions.

Complete the RuleDefinitions section as follows:-

Before:-

<RuleDefinitions>
<TabDisplayRules />
<DisplayRules />
<EnableRules />
</RuleDefinitions>

After:-

<RuleDefinitions>
<TabDisplayRules />
<DisplayRules>
<DisplayRule Id="Mscrm.SaveAndClosePrimary.DisplayRule">
<FormStateRule Default="0" State="Create" InvertResult="true" />
</DisplayRule>
</DisplayRules>
<EnableRules>
<EnableRule Id="Mscrm.SaveAndClosePrimary.EnableRule">
<FormStateRule Default="0" State="Create" InvertResult="true" />
</EnableRule>
</EnableRules>
</RuleDefinitions>

Microsoft have a good list of the various rules that can be implemented within this section. The two shown above will show and enable the button if the form is not in Create mode.

4) Zip, Import and Publish the entity solution and voila!

Advertisements
Leave a comment

6 Comments

  1. Thanks for your tips about this blog. One thing I would want to say is the fact purchasing gadgets items in
    the Internet is not new. Actually, in the past 10 years alone,
    the market for online electronic products has grown drastically.
    Today, you will find practically virtually any electronic system and product on the Internet, from cameras and camcorders to computer spare parts
    and gaming consoles.

    Reply
  2. An impressive share! I have just forwarded this onto a colleague who has been doing a little
    research on this. And he in fact ordered me dinner due
    to the fact that I stumbled upon it for him…
    lol. So allow me to reword this…. Thanks for the meal!!
    But yeah, thanx for spending time to discuss this subject here on your
    website.

    Reply
  3. Good day! I know this is kinda off topic but I’d figured I’d ask.
    Would you be interested in trading links or maybe guest
    writing a blog article or vice-versa? My site goes over a
    lot of the same topics as yours and I believe we could greatly benefit from each other.

    If you might be interested feel free to shoot me an e-mail.
    I look forward to hearing from you! Terrific blog by the way!

    Reply
  4. Hi i am kavin, its my first occasion to commenting anyplace, when i read this article i thought i could also make comment
    due to this good post.

    Reply
  5. Whats up very cool site!! Man .. Beautiful .. Amazing ..
    I’ll bookmark your website and take the feeds also?
    I am happy to find so many helpful information here
    in the submit, we need work out more techniques on this regard,
    thanks for sharing. . . . . .

    Reply
  6. This is my first time pay a visit at here and i am in fact happy to read all at single place.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: