If you’ve ever dabbled with the Ribbon Workbench, you know it’s a game-changer for customizing your Dynamics and Model-Driven UI. But let’s be honest—while it’s a great tool, tweaking specific button behaviors isn’t always straightforward. Sure, it’s easy once you get the hang of it, but without a roadmap, you might find yourself scratching your head.
In this tutorial, I’m diving deep into how you can set the visibility of a button based on the value of a field.
The Scenario
Imagine you’re working on a system that manages project offers. You have a button for creating a project, but you only want this button to appear after a customer has accepted an offer. In essence, the „Create Project“ button should be invisible until the offer’s status changes to „Accepted.“
This isn’t just about hiding or showing a button—it’s about enhancing user experience by presenting options that are contextually relevant. Let’s get into how you can make this happen.
Step-by-Step Guide
1. Open Ribbon Workbench or the XRM ToolBox
- Launch the Ribbon Workbench tool.
- Load the solution that contains your Offer entity. This is crucial because we’ll be modifying the ribbon associated with this entity.
2. Locate or Create the Button
- If you’ve already got a „Create Project“ button, great! Locate it in the command bar.
- If not, you’ll need to create a new button:
- Right-click on the Command Bar and select Add Button.
- Or just drag-and-drop the Button Element
- Configure the button’s properties—give it a label, an icon.
- Right-click on the Command Bar and select Add Button.
3. Define a Command
This is where we set the conditions for when the button should appear, the task the button should do and more…
- In the Ribbon Workbench, find the Command section.
- Right-click and select Add New Command.
3. Define a Display Rule
This is where we set the conditions for when the button should appear.
- Let’s configure this rule:
- Step 1: Add New Display Rule > Value Rule.
- Step 2: Set the Field to the status field of the offer (e.g.,
statuscode
or wwp_status). - Step 3: Set the Value to match the accepted status. You’ll need the actual numeric value that represents „Accepted“ in your system. You can find this by checking the metadata or option set values.
- Step 4: Leave the Invert Result option unchecked, since we want the button to show when the condition is true.
4. Associate the Command with the Button
- Go back to your button’s properties.
- In the Command section, add the command you just created.
5. Save and Publish
Save isn’t available as a button but you can use the shortcut or just publish it directly
- Publish the solution to apply the changes.
- Test it out in your application to confirm that the button only appears when an offer is accepted.
Disclaimer: Since English isn’t my first language, I’ve used AI assistance to correct this article.