Programming

Oracle APEX: Trigger Dynamic Action on Shuttle Close

Learn how to trigger a dynamic action in Oracle APEX when closing a shuttle dialog with selected values. Use apexafterclosedialog event, JavaScript condition for oracle apex item, and refresh interactive grids seamlessly.

1 answer 1 view

Oracle APEX: How to trigger a dynamic action on shuttle close event when values are selected?

I have a shuttle item in Oracle APEX and want to execute a dynamic action when the user closes the shuttle dialog using the ‘X’ button, provided there is at least one value selected on the right side. Is this possible? I found other ‘when’ events available, but none specifically for the shuttle close action.

Yes, in Oracle APEX you can trigger a dynamic action when a user closes the shuttle dialog with the X button—but only if at least one value is selected on the right side—by leveraging the Dialog Closed (apexafterclosedialog) event tied to your shuttle item. This isn’t a shuttle-specific “close” event (there isn’t one), but the framework event catches modal dialog closures reliably, including shuttles. Just add a simple JavaScript client-side condition to filter for selected values, and you’re set.


Contents


Understanding Oracle APEX Shuttle Items

Shuttle items in Oracle APEX are handy for multi-select scenarios. Picture this: left side holds available options, right side your picks. Users drag or shuttle values back and forth in a modal dialog. But what happens when they hit that tempting X to bail out? Does anything fire? Not natively for just the shuttle—no dedicated “shuttle closed” event exists. That’s where dynamic actions shine, letting you react to user behavior without endless PL/SQL.

Shuttles tie into broader Oracle APEX interactive components, like grids or reports. They’re powered by LOVs (lists of values), so they play nice with SQL queries for dynamic populations. Yet, closing the dialog? It bubbles up through APEX’s dialog framework, not as a shuttle-only signal. Frustrating at first, but once you know the trick, it’s straightforward.

Why care? Say you’re building an oracle apex interactive grid or report oracle apex setup. Users select departments in a shuttle, close it, and boom—you refresh a downstream region or submit data. Without this, you’d miss those half-committed changes.


Available Events for Shuttle Components

Oracle APEX exposes events like Change Order [Shuttle] for when users reorder picks inside the dialog. Useful? Sure, for drag-and-drop tweaks. But for closure? Nada specific. The docs list framework events that catch dialog life cycles instead.

From the official Oracle APEX documentation, shuttles trigger component events like Change Order [Shuttle], but dialog close relies on apexafterclosedialog. This fires post-close, whether via X, OK, or Cancel. No shuttle-only close? It’s by design—APEX treats shuttles as modal dialogs under the hood.

Other events? Dialog Opened for entry points, or custom ones via plugins. But for your oracle apex item like P1_SHUTTLE, stick to what’s native. Custom events work too (more on that later), but why reinvent when apexafterclosedialog handles it?


Dialog Closed Event (apexafterclosedialog)

Here’s the hero: Dialog Closed (apexafterclosedialog). It bubbles up whenever any APEX modal shuts, shuttles included. User smashes X after picking values? Fires. Hits Cancel empty-handed? Fires too—but we’ll filter that.

Why does this fit oracle apex shuttle dynamic actions perfectly? Shuttles don’t expose a close button event directly. The framework event grabs it globally, then you scope it to your item. Per the Oracle APEX managing dynamic actions guide, select your shuttle item in the “When – Selection” field. Boom—targeted.

Test it quick: Add a DA with just an alert. Close shuttle any way. You’ll see it pop, proving the hookup works across APEX versions, including 24.2 as of early 2026.


Creating the Dynamic Action

Fire up Page Designer. Right-click Dynamic Actions > Create Dynamic Action. Name it “Shuttle Closed Check” or whatever.

Event: Framework > Dialog Closed (apexafterclosedialog).
Selection Type: Item(s) > P1_SHUTTLE (your oracle apex item).

True Actions? Whatever: Refresh a region, execute JavaScript, submit page. False branch? Optional, maybe clear values or show a nudge.

Static? Nah. This scales for oracle apex interactive reports or grids downstream. Event’s lightweight—no perf hit.

Pro tip: Scope to the shuttle item avoids firing on every dialog close in your app. Clean.


Client-Side Condition for Selected Values

The magic filter. Without it, your DA runs on every close, even empties. Add under Advanced > Client-Side Condition.

Type: JavaScript Expression.
Expression: $v('P1_SHUTTLE').split(',').length > 0

Breaks down like this: $v() grabs the item’s value (comma-separated IDs). Split into array, check length. Got picks on right? True. Empty? Skips.

Why JS? Server-side can’t peek dialog state fast enough. Client’s instant. Handles nulls too—if no value, split yields empty array.

Edge case: Multiple commas from weird LOVs? Trim or filter as needed, but this covers 99%.


Complete Step-by-Step Example

Let’s build it. Assume shuttle P1_DEPARTMENTS feeds an oracle apex grid.

  1. Dynamic Action: ShuttleDialogClosed
  • Event: Dialog Closed (apexafterclosedialog)
  • Selection: Item = P1_DEPARTMENTS
  1. Client-Side Condition:
    JavaScript: $v('P1_DEPARTMENTS').split(',').length > 0

  2. True Action: Execute JavaScript Code

apex.message.showPageSuccess('Selected: ' + $v('P1_DEPARTMENTS'));
apex.region('my_grid').refresh(); // Refresh oracle apex interactive grid
  1. Save, run page. Shuttle, pick values, X out. Alert + grid refresh. Empty close? Crickets.

From the official docs table: Exact match for “Fire a dynamic action when the Shuttle dialog is closed… and at least one value is selected.”

Want SQL? Chain a Submit Page action, process in PL/SQL: IF :P1_SHUTTLE IS NOT NULL THEN...


Testing and Troubleshooting

Hit snags? Console first—F12, watch for JS errors. $v() failing? Item not rendered yet? Rare, but add this.data checks.

Event not firing? Confirm shuttle’s modal (default). Inline? Different story—use Change [Shuttle] instead.

Browser quirks? Chrome/Edge solid; test Firefox. APEX 24.2+ handles shuttles consistently.

No values detected? LOV static IDs match? Debug: Alert $v('P1_SHUTTLE') in a broad DA.

Multi-page app? Namespace items: P1. vs page-scoped.


Best Practices and Alternatives

Keep DAs lean—one per shuttle. Bulk actions? Chain 'em.

Alternatives: Custom HTML button in shuttle? Trigger via apex.event.trigger(document, 'shuttle-closed', {item: 'P1_SHUTTLE'}), per this Medium guide on APEX custom events. Overkill usually.

For oracle apex pl sql fans: Post-close, use page processes. But client-side’s snappier.

Upgrade tip: APEX 24.2+ refines dialog events—no deprecations hit shuttles yet, unlike old LOV escaping quirks.

Scale it: Wrap in app-level DA for shared shuttles. Or plugins for reusable logic.


Sources

  1. Managing Dynamic Actions - Oracle APEX
  2. 13.2 Managing Dynamic Actions - Oracle APEX
  3. Unlock Your APEX UI: Trigger Dynamic Actions from Custom HTML

Conclusion

Triggering oracle apex shuttle dynamic actions on close with selected values boils down to apexafterclosedialog plus a JS length check—reliable, native, no hacks. It unlocks smoother workflows for interactive grids, reports, and beyond. Experiment in a sandbox page; tweak for your LOVs. You’ll wonder how you managed without it.

Authors
Verified by moderation
Moderation
Oracle APEX: Trigger Dynamic Action on Shuttle Close