Reputation: 1
I need some help on how to apply theme style of an application(app_id=101) from another application(app_id=100).
On both the apps I have the same authentication schemes and have enabled session sharing to workspace level. Also the option to modify application(this and other) is enabled under Runtime API Usage on both the apps.
Created a process through a button which picks up app_id and theme_style_id from lov's.
This is what I have on the page process.
declare
l_theme number;
begin
apex_session.create_session (
p_app_id => :P1_APP_ID,
p_page_id => 1,
p_username => 'ADMIN' );
select theme_number into l_theme from apex_application_themes where application_id = :P1_APP_ID and ui_type_name = 'DESKTOP';
apex_theme.set_current_style (
p_theme_number => l_theme,
p_id => :P1_DESKTOP_THEME_STYLE_ID
);
end;
What happens when I click the button is it takes me to the login page of app-101 and applies the theme style after successful login. Is there anyway that it can be done without having to enter the credentials?
Upvotes: 0
Views: 265
Reputation: 18720
I haven't tested this but this is one path you could investigate. Instead of executing the apex_theme.set_current_style
call in the context of your application, you could execute it as a background process using dbms_scheduler
. That way this pl/sql block is decoupled from your current apex session.
Code in page process would be something like this (ids are hardcoded here - but it should give you the idea). It creates, runs and drops a job in the background.
DECLARE
l_job_action VARCHAR2(4000);
l_job_name VARCHAR2(100) := 'CHANGE_THEME_STYLE';
BEGIN
l_job_action := q'!declare
l_theme number;
begin
apex_session.create_session (
p_app_id => 40357,
p_page_id => 1,
p_username => 'ADMIN'
);
apex_theme.set_current_style (
p_theme_number => 10042,
p_id => 182528089935200447
);
end;!';
dbms_scheduler.create_job(
job_name => l_job_name,
job_type => 'PLSQL_BLOCK',
job_action => l_job_action,
enabled => true,
auto_drop => true);
END;
/
Alternatively you could create an automation in your app and run it on demand using APEX_AUTOMATION.EXECUTE
Upvotes: 0