Blog, Development, Howto

HowTo: Show ribbon button depending on Application running

Several days back I saw an email from Steve Mordue MVP asking if it is possible to filter ribbon elements based on application like it’s implemented for entities, views and forms. Answer was that at the moment there is no easy way to do it. In this post I will help Steve to resolve his issue using JavaScript and Ribbon Workbench.

JavaScript

First of all to define what application is running getCurrentAppProperties method can be used. The issue that arises that it returns Promise and not the result itself so to resolve it I’ll use approach similar to this post – by default button is not shown and visibility of it is set in “success” handler of promise. Here is the code:

Create JavaScript webresource with provided script.

Ribbon Workbench

Add a button, add a command and point button to command created, add Enable Rule to command, add custom rule to it:

Save and publish ribbon. The next question is – where can I get application unique name from? Open Model Driven App Designer, open Properties and scroll to bottom. There you can find “Unique Name” field.

Demonstration

Here are 2 different apps with the same forms opened. In first application button is available. In second – it’s not:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.