Tuesday, December 7, 2010

APEX: How to Trigger Dynamic Action From Button

Someone recently asked me how to trigger a dynamic action from a button. At first I thought this was trivial question until I tried to do it and found it's not as straight forward as I expected.

The following steps cover how to create a dynamic action on a button:

Modify Button Template:

You'll need to modify the button template to allow for the button attributes to be applied to the button. This will allow us to use an ID to identify a button. To apply the button attributes go to Shared Components > Templates > Select the default button template (for most instances called "Button"). Add #BUTTON_ATTRIBUTES# to the button tag in the Template section. For example from:

<button value="#LABEL#" onclick="#LINK#" class="button-gray" type="button">


<button value="#LABEL#" onclick="#LINK#" class="button-gray" type="button" #BUTTON_ATTRIBUTES#>

Create Button
On the page you're working on create a Region Button:

Button Name: TEST BUTTON
Label: Test Button
Button Style: Template Based Button
Button Template: Button (or what ever button template you modified)
Button Attributes: id="test_button"
Make sure the id is unique

Action: Redirect to URL
URL Target: javascript:return;

Create Dynamic Action
Create a Dynamic Action. When you get to the "When" section:

Event: Click
Selection Type: DOM Object
DOM Object: test_button
The DOM object represents the ID that you defined while creating the button.
Condition: No Condition

Create your True and/or False actions accordingly.

Now when you run the page and click the button it should execute your dynamic action.


  1. Hi Martin,

    That's the same I encountered a few months ago. I discussed it with Peter and Patrick from the APEX team and they will 'repair' it in the next version if I recall it right.

    Good post,
    Learco Brizzi

  2. i try your solution, exactely same state, but when i pressed button nothing execute

  3. Hi Martin,
    great post. Works like a charm. Thanks.


  4. Hi Marin,

    Thank you for the tips. But not sure about the button template. The problem I have is the page will not refresh after PL/SQL code via dynamic action. I post the question in apex forum. Please check the below.


    Greatly appreciate with any suggestions/corrections.

  5. Hi,
    Followed these steps but it doesn't work 100%.
    The dynamic action I want is the confirm notification and it triggers fine when I press the button, but the problem is if I press 'cancel' it still submits the page...
    is there another way to confirm a page submit? I did try and do it with the dynamic action but 'before page submit' as the when which worked fine...but on all the buttons and I need it on only one.


  6. Hi Jeremy,

    This may be an unrelated issue that you're having with the cancel button. Can you please post an example on apex.oracle.com then email me login credentials so that I can take a look? My email address is in top right (under Links section).