Answered by:
CRM 2011 - Hide a ribbon button based on current form name

Question
-
Hello All,
I have the account entity with 2 forms named: formA and formB. I have a custom ribbon named ribbonA.
On loading an account, depend on the value of an custom attribute of account entity, I show formA or formB.
Is it possible to show ribbonA when formA is displayed and hide it when formB is displayed?
I did some searches but it seems that we cannot use the CustomRule inside the DisplayRule. Please help...
Many thanks!
PS: Jscript to get formId based on its name:
/* Get form id by name*/
function getFormSelectorItemByName(nameRoleForm) {
var formId = null;
Xrm.Page.ui.formSelector.items.forEach(function (item, index) {
var itemLabel = item.getLabel();
if (itemLabel.toLowerCase() == nameRoleForm.toLowerCase()) {
formId = item.getId();
return formId;
}
});
return formId;
}
- Edited by NGMKha Wednesday, June 27, 2012 5:01 AM
Wednesday, June 27, 2012 4:57 AM
Answers
-
For this case you would not be able to hide buttons. You will be able to disable button based on custom rule - http://msdn.microsoft.com/en-us/library/gg309433.aspx
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
- Proposed as answer by Andrii ButenkoMVP, Moderator Wednesday, June 27, 2012 8:29 AM
- Marked as answer by NGMKha Thursday, June 28, 2012 3:45 AM
Wednesday, June 27, 2012 7:58 AMModerator
All replies
-
Hello,
In case form to displayed is dependent on custom attribute you should use the same attribute for configuration of Ribbon Buttons visibility.
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
- Proposed as answer by Andrii ButenkoMVP, Moderator Wednesday, June 27, 2012 8:29 AM
Wednesday, June 27, 2012 6:39 AMModerator -
Hello,
OK. Another case in my business: I have 3 forms named: formDefault, formA and formB.
When the user opens an account, formDefault is loaded by default. Then the user manually selects a form in the form list (via GUI):
-> How can I SHOW ribbonA when the user selects formA and HIDE ribbonA when the user selects formB?
Thanks for your helps.
- Edited by NGMKha Wednesday, June 27, 2012 7:28 AM
Wednesday, June 27, 2012 7:26 AM -
For this purpose you define a RibbonDiffXml within the form element of the customizations.xml.
Export an unmanaged solution which only contains your entity. Get the customizations.xml and edit it. Look for the form XML sections. Within each form you can define a ribbon that is specific for that form. If your ribbon customizations apply to all forms of your entity you can add the RibbonDiffXml one or more levels higher.
Henk van Boeijen
Wednesday, June 27, 2012 7:49 AM -
For this case you would not be able to hide buttons. You will be able to disable button based on custom rule - http://msdn.microsoft.com/en-us/library/gg309433.aspx
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
- Proposed as answer by Andrii ButenkoMVP, Moderator Wednesday, June 27, 2012 8:29 AM
- Marked as answer by NGMKha Thursday, June 28, 2012 3:45 AM
Wednesday, June 27, 2012 7:58 AMModerator -
OK. Impossible to hide Ribbon buttons in my case?!
It's strange that the CustomRule is designed for the EnableRule only?! Not for the DisplayRule.... :(
- Edited by NGMKha Wednesday, June 27, 2012 8:26 AM
Wednesday, June 27, 2012 8:24 AM -
Hello,
This is the thing I'm interested in to. Luckily Microsoft has connect where you can create suggestions for product improvement.
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
- Proposed as answer by Andrii ButenkoMVP, Moderator Wednesday, June 27, 2012 8:31 AM
Wednesday, June 27, 2012 8:31 AMModerator -
Hi,
You can Hide button based on Security Role as below:
Naren
Wednesday, June 27, 2012 1:19 PM -
http://blog.salesmetrix.net/2012/02/17/dynamics-crm-custom-role-based-security-settings-to-enabledisable-native-ribbon-button/
If I'm not wrong even in url you've provided it is written "enable disable". So article actually describes how to enable/disable button based on the custom rule.Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
Wednesday, June 27, 2012 1:37 PMModerator