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!

How to wait until on demand process finishes on dynamic action?

smoliveiraFeb 22 2016 — edited Feb 22 2016

Hi all,

I need to run a PL/SQL function after a user clicks on a button and then show an alert window with a message returned from that PL/SQL function. I am doing that with a dynamic action. First, on the dynamic action I call the "apex.server.process" javascript function to call my PL/SQL function and show the alert window with the message returned by the PL/SQL function.

Javascript code on the dynamic action:

apex.server.process("My Process", {

  pageItems: "#P1_MY_ITEM"

  }, { 

    beforeSend: function(e) {apex.widget.waitPopup();},

    dataType: "text",

    success: function (pData) { 

      if(pData) alert(pData); 

    },

    complete: function() {

       // remove indicator in APEX 4.x

       $("#apex_wait_popup").remove();

       $("#apex_wait_overlay").remove();

    },

  });

On Demand process ("My Process"):

DECLARE

   L_Text_Msg VARCHAR2(400);

BEGIN

   L_Text_Msg := MY_FUNCTION (:P1_MY_ITEM);

   IF L_Text_Msg IS NOT NULL

   THEN

      htp.p(L_Text_Msg);

   END IF;

END;

I want to show the waitPopup while the process is running that's why I have:

beforeSend: function(e) {apex.widget.waitPopup();},

And when the process finishes, I need to remove it:

complete: function() {

       // remove indicator in APEX 4.x

       $("#apex_wait_popup").remove();

       $("#apex_wait_overlay").remove();

    },

Everything goes as expected. My process runs, while is running the waitPopup is showed, when finishes the alert message is displayed with the message and when the user clicks on the "OK" button on the alert window the waitPopup disapears.

However, I have other actions on the dynamic action that I would like to run just after the user clicks on the "OK" button on the alert message, i.e., after my process finishes to run. At this moment, they are running before the process finishes.

Sometimes my function doesn't return any message and no alert window is displayed.

I already read Nick Buytaert's article, but I don't know how to implement the "apex.da.resume" function:

https://apexplained.wordpress.com/2014/01/18/the-apex-da-resume-function/

Can you please tell me how to implement/use the "apex.da.resume" function in order the following actions on the dynamic action just run after the process finishes?

Regards,

Susana

This post has been answered by John Snyders-Oracle on Feb 22 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 21 2016
Added on Feb 22 2016
3 comments
11,211 views