Answered by:
Hide ribbon button using javascript + crm 2011

Question
-
How to hide ribbbon button using javascript + crm 2011Thursday, April 14, 2011 10:45 AM
Answers
-
There are demonstrations of this in the SDK samples.
- Marked as answer by Donna EdwardsMVP Saturday, June 18, 2011 8:54 PM
Saturday, June 11, 2011 4:01 AM
All replies
-
May I ask the purpose of trying to do this?
Jamie Miley
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!Thursday, April 14, 2011 1:18 PMModerator -
I want to hide ribbon button depending on role of user.
Ketan GhuleThursday, April 14, 2011 2:04 PM -
I don't know that there is a supported way to do this unfortunately. It's pretty engrained in the application.
Jamie Miley
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!Thursday, April 14, 2011 5:39 PMModerator -
You should use the RibbonDiffXml (take a look at the sdk) to add this functionality.
1.) You may call a javascriptfunction from a webresource library and set the button enabled/disabled
See: RuleDefinitions => EnableRules => EnableRule => CustomRule
2.) Maybe the displayRules can help you. Here you can check the current users privileges
See: RuleDefinitions => DisplayRules => DisplayRule => MiscellaneousPrivilegeRule
Maybe this puts you in the right direction.
Greets
Dennis
Wednesday, April 20, 2011 10:23 AM -
Hi Ketan,
I am in same boat as you. Did you figure out how to achive it?
Thanks
makeerSaturday, April 23, 2011 6:02 AM -
We need to create custom rule for that then from customrule call javascript which returns either true or false.
then that button can be disabled.
From SDK-> get command defination form leadform-> then add your enable rule->can create add custom rule
CRM LEARNINGMonday, April 25, 2011 4:45 AM -
If you can accomplish this with a custom rule, I would say check this link out.
http://howto-mscrm.blogspot.com/2011/04/how-to-series-6-how-to-use-customrule.html
Jamie Miley
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!Monday, April 25, 2011 2:45 PMModerator -
Actually its not a Custom Button that I wanted to hide n show, its CRM's outof box button.
Depending upon certain condition on an Entity I wanted to hide-n-show "Add Contact" button on the Entity Details form (Contact is having many-to-many relationship with this entity)
makeerTuesday, April 26, 2011 11:18 PM -
Hi Ketan.
I am not sure, whether you can hide a button on such a condition. Coz, i am also searching for such a solution. But you can disable/enable based on javascript function.
You can get all the entities RibbonXML using the exportribbonxml tool provided with SDK [sdk\samplecode\cs\client\ribbon]. Open the ribbonxml corresponding to your entity, identiy the command definition corresponding to the button you want to hide. Copy this code. Now export your entity in a solution, open the customizations file and add this commanddefinition under the commanddefinitions node of your entity. Add a new enable rule with the functionality you want.
<CommandDefinitions>
<CommandDefinition Id="Mscrm.AddNewRecordFromSubGridStandard">
<EnableRules>
<EnableRule Id="Mscrm.AppendToPrimary" />
<EnableRule Id="Mscrm.EntityFormIsEnabled" />
</EnableRules>
<DisplayRules><!-- Here I am adding my Own Display Rule -->
<DisplayRule Id="Mscrm.Isv.AddNew" /><!-- Here I am adding my Own Display Rule -->
<DisplayRule Id="Mscrm.ShowForOneToManyGrids" />
<DisplayRule Id="Mscrm.AppendToPrimary" />
<DisplayRule Id="Mscrm.CreateSelectedEntityPermission" />
<DisplayRule Id="Mscrm.AppendSelected" />
<DisplayRule Id="Mscrm.HideAddNewForChildEntities" />
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName="Mscrm.GridRibbonActions.addNewFromSubGridStandard" Library="/_static/_common/scripts/RibbonActions.js">
<CrmParameter Value="SelectedEntityTypeCode" />
<CrmParameter Value="PrimaryEntityTypeCode" />
<CrmParameter Value="FirstPrimaryItemId" />
<CrmParameter Value="PrimaryControl" />
</JavaScriptFunction>
</Actions>
</CommandDefinition></CommandDefinitions>
This is my Rule Definitions.
<RuleDefinitions>
<TabDisplayRules />
<DisplayRules>
<DisplayRule Id="Mscrm.Isv.AddNew">
<ValueRule Field="new_type" Value="2" InvertResult="true" />
</DisplayRule></DisplayRules>
<EnableRules />
</RuleDefinitions>
Here I am trying to Hide the "Add New" Button. You can use a similar code to enable/disable. :)
Thanks & Regards, JohninfantTuesday, May 17, 2011 10:46 AM -
I tried it but somehow it does not worked for me?
Its not throwing eny error also so very difficult to debug.
makeerWednesday, May 18, 2011 8:02 AM -
I finally got it working. I have to give different Id to CommandDefinition since if we use original CommandDefinition even though we make changes in Copied CommandDefinition, it always takes original CommandDefinition.
makeer- Proposed as answer by Makarand Keer Monday, May 23, 2011 3:00 AM
Monday, May 23, 2011 3:00 AM -
There are demonstrations of this in the SDK samples.
- Marked as answer by Donna EdwardsMVP Saturday, June 18, 2011 8:54 PM
Saturday, June 11, 2011 4:01 AM -
Hi,
Custom rule can be created for Ednable,Disable. There is a way to hide the button making changes to XML ‘HideCustomAction’ . This will hide the button from ribbon,but in-case if you have role based form for that entity,it wont display the button for it. It can be only hide / display.
Regards,
Ranjeet
Wednesday, July 13, 2011 4:56 AM -
this could help:
http://dynamicscrm2011.wordpress.com/tag/enable-crm-2011-ribbon-button/
Just make sure you use the Display Rules (since you are hiding), instead of the Enable Rules
http://radiateeverything.blogspot.com/Thursday, July 21, 2011 2:21 PM -
Hi,
I have a situation where i have to hide 'Deactivate' Button on Role-based Security.
Can the Above mentioned code implemented for the same. I do not want to use the Javascript.
Is it possible to Hide/Show the Ribbon button without using JavaScripts.
Please let me know.
Puneet Joshi
Thursday, February 23, 2012 5:46 PM -
check this
http://www.ahmetcankaya.com/hide-ribbon-button-in-crm-2011-by-using-javascript/
Crm Software Specialist
Tuesday, May 8, 2012 8:16 AM -
Here's a way to accomplish this : http://blog.customereffective.com/blog/2012/05/managing-activatedeactivate-permissions-of-crm-entities.html
Scott Sewell, CustomerEffective | http:\\blog.CustomerEffective.com | Twitter:@ScottSewell
- Proposed as answer by Scott Sewell, Hitachi SolutionsModerator Tuesday, June 5, 2012 6:52 PM
Tuesday, June 5, 2012 6:52 PMModerator