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">

To:

<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.