Hi all,
I'm trying to dynamically change the theme style in Oracle APEX at runtime using the APEX_THEME.SET_CURRENT_STYLE procedure. Here's my full setup:
π§ Setup Details
β
Page Item:
Created a select list item P0_THEME_STYLE on the Global Page (Page 0).

β
SQL Query for Select List:
SELECT s.name d, s.theme_style_id r
FROM apex_application_theme_styles s,
apex_application_themes t
WHERE s.application_id = t.application_id
AND s.theme_number = t.theme_number
AND s.application_id = :APP_ID
AND t.ui_type_name = 'DESKTOP'
AND t.is_current = 'Yes'
ORDER BY 1

β
Source (Return Single Value SQL Query):
SELECT s.theme_style_id
FROM apex_application_theme_styles s,
apex_application_themes t
WHERE s.application_id = t.application_id
AND s.theme_number = t.theme_number
AND s.application_id = :APP_ID
AND t.ui_type_name = 'DESKTOP'
AND s.is_current = βYesβ

β
Server-side Condition (Row Exists):
SELECT 1
FROM apex_application_theme_styles s,
apex_application_themes t
WHERE s.application_id = t.application_id
AND s.theme_number = t.theme_number
AND s.application_id = :APP_ID
AND t.ui_type_name = 'DESKTOP'
AND t.is_current = 'Yes'

βοΈ Dynamic Action on Change (PL/SQL Code):
IF :P0_THEME_STYLE IS NOT NULL THEN
FOR c1 IN (
SELECT theme_number
FROM apex_application_themes
WHERE application_id = :APP_ID
AND ui_type_name = 'DESKTOP'
AND is_current = 'Yes'
) LOOP
apex_theme.set_current_style(
p_theme_number => c1.theme_number,
p_id => :P0_THEME_STYLE
);
END LOOP;
END IF;


β
APEX Runtime Output Current Theme Vita - Dark

β
Change Theme Vita - Dark to Vita - Red

β
Followed by a "Submit Page" and "Refresh" action.
β Issue / Clarification
In some cases, this works fine after page submit. But in a few environments (or when trying APEX_THEME.SET_CURRENT_STYLE), I get:
"An API call has been prohibited. Contact your administrator."
π Debug ID Example: 1743603233
β
Solution:
Go to:
Shared Components β Security Attributes β Advanced β Runtime API Usage
Then:
π Set "Modify This Application" to "Enabled"
This resolved the error, and the dynamic theme switching now works perfectly.

π‘ Notes:
- I'm using APEX 22.x / 23.x
- Theme: 42 - Universal Theme
- The change is session-specific, not global
- Purpose: Allow user to switch between Light/Dark themes from global menu
Any insights or improvements are appreciated!
Thanks in advance.