rules repository

A-1390 Avoid buttons defined by dynamic action without a dynamic action.

Severity Warning SQL-based Test Free New

Reason

A button with the action Defined by Dynamic Action does nothing by itself: it neither submits the page nor redirects. If no dynamic action reacts to its click, the button is dead, and users click it without any effect.

Create a dynamic action with the event Click, selection type Button and this button, or change the button's action to Submit Page or a redirect. If the button is wired up another way (a dynamic action with a jQuery selector such as a shared CSS class, the actions framework through data-action / apex.actions, or JavaScript bound to the button's static ID), the check cannot see that link; prefer a dynamic action with selection type Button, or document the wiring in the button's comments.

Example

Non-Compliant Example

page 10 (
    // ...
    button refresh (
        buttonName: REFRESH
        label: Refresh
        // ...
        behavior {
            action: definedByDynamicAction
        }
    )
)
Issues
LineColumnMessage
821Button is defined by dynamic action, but no dynamic action reacts to it.

Compliant Solution - ★★★★★

page 10 (
    // ...
    button refresh (
        buttonName: REFRESH
        label: Refresh
        // ...
        behavior {
            action: definedByDynamicAction
        }
    )

    dynamicAction refresh-customers (
        name: Refresh customers
        when {
            event: click
            selectionType: button
            button: @refresh
        }
        // ...
    )
)

Tests

Test SQL query

select aa.workspace || '.' || aa.alias || '.' || b.page_id || '.' || coalesce(b.static_id, to_char(b.button_id)) as identifier,
       'Button ' || b.button_name || ' on page ' || b.page_id || ' of app ' || aa.alias || ' in ' || aa.workspace
         || ' is defined by dynamic action, but no dynamic action reacts to it.' as message
  from apex_application_page_buttons b
  join apex_applications aa
    on aa.application_id = b.application_id
       and aa.workspace = b.workspace
 where aa.workspace in (#ApexWorkspaces#)
   and b.button_action_code = 'DEFINED_BY_DA'
   and not exists (select 1
                     from apex_application_page_da da
                    where da.application_id = b.application_id
                      and da.when_button_id = b.button_id)

Test results

IdentifierMessageMigration
WORKSPACE.CUSTOMERS.10.refreshButton REFRESH on page 10 of app CUSTOMERS in WORKSPACE is defined by dynamic action, but no dynamic action reacts to it.-

Parameters

Use parameters to customize the rule to your needs.

ParameterDescriptionDefault Value
ApexWorkspacesComma-separated List of APEX workspaces owning APEX applications to check.dblinter, dbl_gui

References