Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Best Practice for Dynamically Changing Theme Style in Oracle APEX using APEX_THEME.SET_CURRENT_STYLE

Harsh PanchalMay 16 2025 — edited May 20 2025

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.

Comments
Post Details
Added on May 16 2025
2 comments
1,054 views