oracle apex redirect to modal dialoge page from pl/sql code

Nidheesh picture Nidheesh · Jan 27, 2018 · Viewed 8k times · Source

I have a page process in my apex page. I want to redirect to a modal dialoge page after the page process finishes. So I wrote the code

htp.init;
owa_util.redirect_url('f?p=&APP_ID.:34:APP_SESSION.::NO:34:P34_CODE,P34_DAY_DATE:P30_CODE.,'||:P30_DAY_DT); 
apex_application.stop_apex_engine;

The page 34 is a modal dialoge page . Hence it shows error

page 34 cannot be rendered successfully. Ensure the page template in use on page 34 is of template type "Dialog page", with appropriate JavaScript dialog initialization, dialog closure and dialog cancel code defined.

Then I tried with

 l_url:=APEX_UTIL.PREPARE_URL('f?p=&APP_ID.:34:APP_SESSION.::NO::P34_CODE,P34_DAY_DATE:P30_CODE.,'||:P30_DAY_DT',p_checksum_type=>'SESSION'); 
 htp.init;
 apex_util.redirect_url(l_url);
 apex_application.stop_apex_engine;  

That too didn't worked for me. Anybody have solution?

Answer

Nidheesh picture Nidheesh · Feb 3, 2018

create a dynamic action for the button, copy the pl/sql code in page process and then add an action "execute pl/sql code" in dynamic action.Paste the copied code there.

declare
   v_url varchar2(4000);
begin

   v_url:=apex_util.prepare_url
                  (p_url             =>  'f?p=&APP_ID.:34:&SESSION.:::34:P34_CODE:'|| :P30_CNAME,
                   p_triggering_element      =>'$(''#URLS'')'
                  );
   :p30_URL:=v_url;
end;

after this pl/sql, create a javascript action for the same dynamic action and write

 eval($('#P30_URL').val());

eval() is a default js method.This will redirect to modal page