Thursday, 5 February 2015

Control Ribbon Visibility (Show/Hide) based on Specific Form in CRM 2011/2013/2015 Multiple Entity Forms

CRM Supports Multiple Forms and we can put ribbon (button in CRM) or Command in the CRM Forms as well. What if we have requirement to show or hide the ribbon based on Form. In this post I will give example of the code to control ribbon visibility.


I have scenario that I have 3 Forms of Account Form.


Now, I want to place a ribbon applicable for Account Form, but only for Partner Form. So when the users are in different form, other than Partner Form, this ribbon should not be available.

The Code

The code is in JavaScript code and it’s pretty simple.

function controlFormRibbon() {
   var formLabel;
   var currForm = Xrm.Page.ui.formSelector.getCurrentItem();
   formLabel = currForm.getLabel();

   //this code to show the ribbon if only the current opened form is Partner, 
   //otherwise remain disable/hidden
   if (formLabel == "Partner") //change this with your own specific form name
      return true;
      return false; 
   //you can also apply the different/reverse rule here, for example you want to hide if form is Partner

Ribbon Workbench Favor

Here, I need a favor from my favorite tool.

I have solution with the ribbon image and script now I just want to place a ribbon and set the JavaScript there.

I create a Button in the Form section, give the Command, rename the Id, assign the Images to the Ribbon.


Then I rename the Label to ‘Partner Only’ that you can see in the final result showing this label Text.

Then Here is the Command.


I apply a Rule here to EnableRules.

This is my rule:



*You can change the Default to True/False to set the default visibility, but in my script I have set other than Partner, will hide this ribbon button, so I don’t bother to change to False.

The key here is just referring the correct FunctionName under the correct Library (your Web Resource where you kept the script) and set parameters if any.

Note: The display rules doesn’t support CustomRule, so just apply it to the EnableRule to show/hide.


I can navigate using Form Selector


*My Partner Form


*My Account & Information Forms


As you can see the ribbon is there if I choose the form to Partner, otherwise it’s hidden.

Hope this can help you!

Thank you.


  1. This comment has been removed by the author.

  2. I tried using this method and at one time I think it initially worked, but after making some additional changes within CRM, it stopped working. It took me a while to figure out the problem. Read which further down says that Xrm.Page.ui.formSelector.getCurrentItem() only works in certain conditions. If a user only has access to one form, this does not work.

    I've not found a similar solution that does work, though. In my instance the user's I'm trying to control the ribbon visibility for only use this one entity form anyway and they all have a custom security role in common, so I'm just going to create a custom entity that this role has access to and use a 'Entity Privilege Rule' to that entity to show/hide buttons.

    It was either this or create a custom field on the form as suggested in the discussion I linked to.

    This blog comment section really needs an edit button. :P

  3. This comment has been removed by the author.

  4. why this isn't work in dinamic crm2016 ?

  5. Ooh love this idea! It's awesome! You can get ribbons with 196 colors and 19 sizes for choice from Yama Ribbon!

  6. I am completely inspired with the accurate change aptitude of creator utilized for changing his contemplations and exhibited here. Inspired with profound importance of this article. programa para baixar musica

  7. I have read your blog its very attractive and impressive. I like your blog salesforce Online Training Hyderabad


  8. This post is really nice and informative. The explanation given is really comprehensive and informative.I want to inform you about the salesforce business analyst training and video tutorials . thankyou . keep sharing..


My Name is..