5 Replies Latest reply: Jun 14, 2012 8:25 AM by Tom Petrus RSS

    Apex 4.0 Ondemand Process -- Ajax Callbacks

    912385
      Hi,

      I am dynamically creating a HREF link in my Apex report using SQL. this links invokes an Ajax Process on the same page.

      The process is an on Demand Ajax Call back that calls a Stored Proc.

      All seems to work as expected, with one small issue, A blank page is displayed once the process is called, the process page does not return back to the page it was called from. Can someone let me know where i am going wrong.

      This is the Query i use to create a dynamic HREF via my Report SQL ...Notice the <a href...> syntax. The name of the process flow is CALL_PROCESS_FLOW

      select "RUN_ID",
      "JOB_NAME",
      "JOB_START_DATE",
      "JOB_END_DATE",
      'Ajax' SP1
      from "#OWNER#"."VW_JOB_CONTROL"
      where job_name='CLN_INPATIENT_FCE'


      I have tried getting rid of the colons after the name of the process flow. I have also tried the same with and without the # at the end. However it still returns the same error.

      Can some one help. I know its something small but i just can seem to figure it out.
        • 1. Re: Apex 4.0 Ondemand Process -- Ajax Callbacks
          VC
          KP wrote:
          Hi,

          I am dynamically creating a HREF link in my Apex report using SQL. this links invokes an Ajax Process on the same page.

          The process is an on Demand Ajax Call back that calls a Stored Proc.

          All seems to work as expected, with one small issue, A blank page is displayed once the process is called, the process page does not return back to the page it was called from. Can someone let me know where i am going wrong.

          This is the Query i use to create a dynamic HREF via my Report SQL ...Notice the <a href...> syntax. The name of the process flow is CALL_PROCESS_FLOW

          select "RUN_ID",
          "JOB_NAME",
          "JOB_START_DATE",
          "JOB_END_DATE",
          'Ajax' SP1
          from "#OWNER#"."VW_JOB_CONTROL"
          where job_name='CLN_INPATIENT_FCE'


          I have tried getting rid of the colons after the name of the process flow. I have also tried the same with and without the # at the end. However it still returns the same error.

          Can some one help. I know its something small but i just can seem to figure it out.
          I don't think you are making an ajax call here and you are just invoking the APEX application process via URL

          Use the below javascript function to make a call ajax
          function myAjaxProcess() {
          var get = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=CALL_PROCESS_FLOW',$v('pFlowStepId'));
           //invoke it now
           gReturn = get.get();
          // you can alert the ajax call back
          //alert(gReturn);
          }
          Replace your href value (href="f?p=&APP_ID.:2:&SESSION.:APPLICATION_PROCESS=CALL_PROCESS_FLOW:::::#")

          like this
          href="javascript:myAjaxProcess();"
          • 2. Re: Apex 4.0 Ondemand Process -- Ajax Callbacks
            912385
            VC,

            Works a Treat mate!!

            Thanks a ton for the quick reply.

            Regards,

            KP
            • 3. Re: Apex 4.0 Ondemand Process -- Ajax Callbacks
              Tom Petrus
              I don't mean to be pedantic or anything, but i'd just like to mention the un-ajax-ness of htmldb_get for a second here. The call is synchronous, as is evident with get.get() : you are simply waiting here for the call to finish and then continue. True ajax is asynchronous, and has you providing a callback handler.
              So, i'd just like to drop this here, as an example and alternative :-)
              $.post('wwv_flow.show', 
                     {"p_request"      : 'APPLICATION_PROCESS=CALL_PROCESS_FLOW',
                      "p_flow_id"      : $v('pFlowId'),
                      "p_flow_step_id" : $v('pFlowStepId'),
                      "p_instance"     : $v('pInstance')
                     },
                      function(data){ 
                       //handle the return here
                       alert(data);
                      }
                     );
              • 4. Re: Apex 4.0 Ondemand Process -- Ajax Callbacks
                VC
                Tom wrote:
                I don't mean to be pedantic or anything, but i'd just like to mention the un-ajax-ness of htmldb_get for a second here. The call is synchronous, as is evident with get.get() : you are simply waiting here for the call to finish and then continue. True ajax is asynchronous, and has you providing a callback handler.
                So, i'd just like to drop this here, as an example and alternative :-)
                $.post('wwv_flow.show', 
                {"p_request"      : 'APPLICATION_PROCESS=CALL_PROCESS_FLOW',
                "p_flow_id"      : $v('pFlowId'),
                "p_flow_step_id" : $v('pFlowStepId'),
                "p_instance"     : $v('pInstance')
                },
                function(data){ 
                //handle the return here
                alert(data);
                }
                );
                Excellent! and even I like this because it uses jQuery.

                But the above code was just an example using apex API's which uses native JavaScript and not jQuery.
                • 5. Re: Apex 4.0 Ondemand Process -- Ajax Callbacks
                  Tom Petrus
                  VC wrote:
                  Excellent! and even I like this because it uses jQuery.

                  But the above code was just an example using apex API's which uses native JavaScript and not jQuery.
                  I understand it was an example :-) It's just that i frequently see people use and mention htmldb_get, perhaps without fully realizing what it does and means, and i wanted to shed a little light on that.
                  Even so, htmldb_get is an undocumented feature; though it's not like to be removed real soon seeing how it is used in each and every apex javascript.

                  And on the topic of native javascript vs jQuery: i'd always prefer jQuery in web development - but that is another discussion.