McRivers
McRivers

Reputation: 373

Redirect/Refresh Page Using Dynamic Action - Oracle Apex 21.1

I have a page (Page 7) where user accounts can be created. When a user clicks the Add User button, the user goes through a Create New User Account flow. This flow follows 3 steps:

When the user clicks the Close button in Step 3, I would like:

Since there is no submit action (PROCESS) in Step 3 - it is just presenting data - I assumed I can not use a branch like Steps 1 and 2. I need to rely on a Dynamic Action. So I tried setting up a DA triggered on the Dialog Closed event that Executes Server-side Code:

DECLARE
  vc_Page7_URL  VARCHAR2(4000);
BEGIN
  vcPage7_URL := apex_page.get_url(
    p_page   => 7,
    p_items  => 'P7_USERNAME',
    p_values => :P12_USERNAME
  );

  apex_util.redirect_url(
    p_url => vc_Page7_URL
  );
END;

This is not working as I expect. I'm obviously overlooking something here. I log the url in the code above to the debug stack and the url is being generated correctly, but I'm not getting a redirect to Page 7. Any help would be appreciated.

Upvotes: 1

Views: 10855

Answers (2)

McRivers
McRivers

Reputation: 373

Per @koen's recommendation, I changed the above code to be 2 TRUE actions under the Close Dialog event that is attached to the Click event of the Done button:

  1. Execute Server-side Code:
BEGIN
 -- i created a hidden page item to hold the URL
 :P12_REDIRECT_URL := apex_page.get_url(
   p_page   => 7,
   p_items  => 'P7_USERNAME',
   p_values => :P12_USERNAME
 );
END;
  1. Execute JavaScript Code:
let url = $v("P12_REDIRECT_URL");
apex.navigation.redirect(url);

Upvotes: 2

Koen Lostrie
Koen Lostrie

Reputation: 18665

I'm not sure that will ever work - you can't do a redirect from within pl/sql in a dynamic action process. The pl/sql code is running in the background and cannot redirect the page. There are 2 options

  1. Change true action on page 7 to submit page and add a branch to redirect to the url of your choice
  2. Redirect using javascript (google it, you'll find several links on that)

Upvotes: 2

Related Questions