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.


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.


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

2 Comments on “HowTo: Show ribbon button depending on Application running

  1. Nice Article Andrew,
    The Classic Ui has the unresolved promise for the formContext.context.getCurrentAppProperties() call due to which it will neither lands up in success nor in error method.
    If the customer still needs both the interfaces i.e. Classic UI as well as Unified Interface then how to handle this unresolved promise in Classic UI?

    1. Anubhav,
      I believe you can do following:

    2. Open support ticket with Microsoft asking to fix their bug (because unresolved promise looks for me as a bug)
    3. As a workaround you can extract appid from the top window url and use it to obtain app name or other properties you need
    4. Andrew

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.