I wanted to change dynamically the style of the theme of my application so you could easily see if you are running the application in development, test, acceptance or production.

One solution is of course to add a global variable to the title of the application and fill this variable with the text you base on the database or settings in a table. However sometimes as developer you even miss that piece of text. I wanted the color of the header to change between environments.

It’s quiet easy to realise with theme-style. I just copied a style from a theme and changed the global color(s) and saved it again a separate style (Visa-Dev, Visa-Test,…). When the application is starting I check the environment (database or parameter table) and set the correct template-style in the initialisation-phase.

apex_theme.set_current_style (p_theme_number => :ID of theme (universal)
,p_id => :ID of choose theme style);

You need the id of the current theme and the id of the style you want to set.

SELECT s.name      name_theme
, s.theme_style_id   id_thema_style
, t.theme_number   id_thema
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 s.name = :theme_name
AND t.ui_type_name = ‘DESKTOP’
AND t.is_current = ‘Yes’

To change the theme-style dynamically you have to change a setting fo the application: Shared components – Security Attributes – Database session – Runtime Api Usage – Modify this application.

Categories: Apex