06 February 2012

APEX: Show Actions menu with Authorization

With an Interactive Report you can choose whether you want the Actions Menu to be shown or not. This has to be done by the developer. Of course the customer wanted to have this based upon the existing authorization scheme. How can you solve this? Dynamic Actions to the rescue.
Go to the Interactive Report page where you want to base the Actions Menu upon the existing authorization scheme. And right click on the "Dynamic Action" in the tree view, and choose "Create".
In the wizard that follows choose the "Advanced" option (no screenshot). Provide a name for the Dynamic Action, like "Hide Actions Menu"
The next step in the wizard asks when the Dynamic Action is supposed to fire, in our case we want it to fire when the Page Loads - and that's what we will pick from the list.
The action that needs to be taken is a little bit of javascript, actually jQuery.
This little bit of jQuery states: "Remove the element from the page which ID has a value of apexir_ACTIONSMENUROOT".
Because we don't want this Dynamic Action to control anything else, we can leave the next step default.
Now we're almost done, the last step is to get the Authorization Scheme attached to the Dynamic Action.
In this screenshot I only have "Must Not Be Public User", but you get the drift.
And there you have, an Actions Menu based upon an existing Authorization Scheme.

Why not with a simple Hide action?

When I showed this to my colleague Marc, he showed me that something similar can be done by a simple Dynamic Action.
When you choose to hide the Actions Menu, as shown in the above screenshot, advanced users - hackers, if you will - can make the Actions Menu visible. And when it is visible, you can execute all the actions from the Actions Menu. How do you make it visible after it is hidden? By using a single line of jQuery:

My advise would be to remove the Actions Menu from the DOM, as shown before, instead of simply hiding the Actions Menu.

Update (06 Feb 2012 18:05)

Maybe it's better to use this jQuery selector to remove the Actions Menu:

The other selector leaves some items of the Actions Menu in the DOM... and we don't want that.

Update (27 Jun 2012 10:40)

Arian (from the comments below) suggests to use the "After Refresh Region" event to implement this functionality instead of the "Page Load" event.
Using this event will prevent the Action button from appearing when the Interactive Region is refreshed.
Thank you for this suggestion, Arian.


jQuery Remove API


  1. Hi Alex,

    Thanks for that one. Very useful. A question remains: how do I find out what the names are for certain objects within the Page, like in this instance "apexir_ACTION_MENU"?

    Have a weekend!

  2. Hi tokke, Thank you for your comment. You can find this information by looking at the generated HTML code. My main development browser is Chrome and there I can use F12 to inspect the elements on the page. When you have Firefox with Firebug you can use the same F12 to inspect the page elements. In the latest version of Firefox you don't even need Firebug to inspect elements, just right click and in the context menu you can see an "Inspect" option.
    Hope this helps you further.

  3. Hi Alex,

    Thanks for the example.

    I think it's better to define as an event 'After Refresh Region' instead of on 'Page Load'.
    Otherwise the 'ACTION' button will appear everytime you are using the standard filter option or another function that will be available despite of not having a 'ACTION' button.


  4. Thank you Arian for this suggestion, I updated the post.

    1. Hi,

      Can I use this approach to remove the option to remove the filter? ( saved before by dev )

    2. Hi Marcel,
      yes you can..
      1) Create the filter that you want to use.
      2) Save the report as the default (as developer)
      3) Uncheck the "Filter" option from the Report Attributes (see the first image)
      4) add a little bit of jQuery: $('#apexir_CONTROL_PANEL').remove()

      If you always want to use the same filter, why don't you alter the query? In my opinion it would perform better.