3 Replies Latest reply: Jun 1, 2012 6:54 AM by nscglr RSS

    Print a success Message on Page in Dynamic Action

    nscglr
      Hi guys,

      I have a dynamic action that executes a pl/sql code block. I need to display a message when this procedure is completed. I tried several options like using "apex_application.g_print_success_message" but I couldn't achieve this. Here is my plsql code :

      CREATE OR REPLACE PROCEDURE processAlrm
      (
      p_alarmAction IN VARCHAR2
      ,p_alarmID IN VARCHAR2
      )
      AS
      BEGIN
      update .......;
      COMMIT;
      apex_application.g_print_success_message := '<span style="color:red">Alarm processed successfully.</span>';
      EXCEPTION
      WHEN OTHERS
      THEN
      ROLLBACK;
      RAISE;
      END processAlarm;
      /


      Do you have any idea how can I do this?

      Thanks.
        • 1. Re: Print a success Message on Page in Dynamic Action
          Prabodh
          Hi,
          Setting the apex_application.g_print_success_message variable will not work as it is used only during page rendering.

          What you could do is
          a. Create a hidden item on the page, say P1_FOR_DA_HDDN
          b. In your DA make the following change
          --apex_application.g_print_success_message := 'Alarm processed successfully.'; 
          apex_util.set_session_state('P1_FOR_DA_HDDN', TO_CHAR(SYSTIMESTAMP) ); 
          -- SYSTIMESTAMP is only to force a change in the item every time the process is run. Alternate to using null/not null or other values.
          c. In the DA's "Page Items to Return" enter P1_FOR_DA_HDDN
          d. Create a DA on P1_FOR_DA_HDDN, event On Change, that has True Action "Alert" and give the message "Alarm processed successfully." in it.

          Here is what will happen
          1. When the process is run the hidden item value will change
          2. Change in value of hidden item will trigger the "On Change" DA on it.

          It will show an Alert box, not in the SuccessMessage area. But as your purpose is to inform the user , I believe this will suffice.

          Regards,
          • 2. Re: Print a success Message on Page in Dynamic Action
            VC
            nscglr wrote:
            Hi guys,

            I have a dynamic action that executes a pl/sql code block. I need to display a message when this procedure is completed. I tried several options like using "apex_application.g_print_success_message" but I couldn't achieve this. Here is my plsql code :

            CREATE OR REPLACE PROCEDURE processAlrm
            (
            p_alarmAction IN VARCHAR2
            ,p_alarmID IN VARCHAR2
            )
            AS
            BEGIN
            update .......;
            COMMIT;
            apex_application.g_print_success_message := '<span style="color:red">Alarm processed successfully.</span>';
            This PL/SQl global variable will only be useful when the page is rendering and it will not change the message once the page is rendered.
            EXCEPTION
            WHEN OTHERS
            THEN
            ROLLBACK;
            RAISE;
            What happens if there is any error?
            END processAlarm;
            /


            Do you have any idea how can I do this?

            Thanks.
            In your Execute PL/SQL Code set the checkbox stop execution on error

            Create an another true action in the same dynamic action as > notification > alert > enter your success message.

            So once the plsql action is successfully executed, it reaches this point and shows the success message.

            If the plsql fails with error then dynamic action stops there and no alert is shown.

            You may also download and install Notification plugin to make the alert look better
            http://www.oracle.com/technetwork/developer-tools/apex/application-express/apex-plug-ins-182042.html#dynamic
            • 3. Re: Print a success Message on Page in Dynamic Action
              nscglr
              Oh, I couldn't set two correct answers. Thank you very much for your help.

              And I like this notification plugin.! Thanks.

              Edited by: nscglr on May 31, 2012 11:53 PM