Most times, requirement is as simple as being able to show or hide a ribbon button based on a value of the field on the record.
Let’s consider this scenario, a button on Lead entity called as “Evaluate” exists. It should be only visible if the Lead Source (OptionSet) is set to Partner.
And the button should be hidden if the condition is not satisfied.
Enable Rule based on Value
Now, let’s see how we achieve this –
- In Ribbon Workbench, in your Command which is tied to the button, you need to add a Display Rule.
- In the Display Rule, you’ll need to select ValueRule.
- In the value Rule, you’ll need to specify the field name and the value to consider.
So here, the field I want to consider is “leadsourcecode” i.e. “Lead Source” field on the Lead entity and 4 is the value of the Partner option.
- and finally make sure your Display Rule is correctly tied to the Command on the button (And yes, the Command should also be tied to the Button itself.)
- And finally Publish your changes.
Now, when the Lead has value as Partner, the button will be visible
And when the value is something else, it will be hidden once the record is saved.
Note: In this case if your condition is based on multiple values, consider adding more Display Rules and patch them together using OrRule as one Rule will cater to only 1 value.
Hope this helps!
Here are some more Ribbon Workbench related posts you might want to check out –
- Get GUID of the current View in Dynamics 365 CRM JS from ribbon button | Ribbon Workbench
- Pass Execution Context to JS Script function as a parameter from a Ribbon button in Dynamics 365 | Ribbon Workbench
- Pass selected rows’ GUIDs to ribbon button in D365 | Ribbon Workbench
- Debug Ribbon button customization using Command Checker in Dynamics 365 CE Unified Interface
- Show Ribbon button only on record selection in Dynamics CRM
- Hide Custom Ribbon Button [Easy Way] – Ribbon Workbench
- Enable Flow button on D365 Ribbon
- [SOLVED] Navigating URL from Ribbon’s custom button in Dynamics for Phones app
- Create a New Record button for Activity Type entity using Ribbon Workbench: D365
- D365 Ribbon Button shortcut to open a Document in SharePoint Online