13 Replies Latest reply: Mar 11, 2013 4:38 AM by Tonito99 RSS

    Master detail form issue retrieving service price automatically

    Tonito99
      Hi,

      I developed a master detail form in order to process service requests.

      On details block I'm trying to retrieve automatically service price after I select service name from LOV.

      For this purpose I created a application plsql process

      declare

      v_price service.price%type;

      begin
      select     price into v_price
      from      service
      where      service_no = 1;

      htp.prn(v_price);
      exception when others then htp.prn('An error occurred retrieving the PRICE');

      end;

      Which process I'm calling through javascript function in order to retrieve service price.

      <script type="text/javascript">

      function GetServicePrice(pThis)
      {   
      var vRow = pThis.id.substr(pThis.id.indexOf('_')+1);
      html_GetElement('f07_'+vRow).value = new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=getPrice',0);
      }

      </script>

      Instead of price it returns this value: "[object Object]".
      Is it possible to work as I intended or it should other way around?

      I appreciate your help/comments.

      Application Express 4.2.1.00.08
      Oracle Database 11g Express Edition Release 11.2.0.2.0

      Regards,
        • 1. Re: Master detail form issue retrieving service price automatically
          Tom Petrus
          html_GetElement('f07_'+vRow).value = new htmldb_Get(null,html_GetElement('pFlowId').value,'APPLICATION_PROCESS=getPrice',0);
          "new htmldb_Get" will only create a new object of that type. It represents the request, but it has not performed that yet. Your process has not been called at all, and you are putting this request object in your input item's value.
          What needs to happen is to actually execute the request, and then put the return from that in your item.
          var ajaxRequest = new htmldb_Get(null, $v('pFlowId'), 'APPLICATION_PROCESS=getPrice', 0);
          var ajaxReturn = ajaxRequest.get();
          $s('f07_'+vRow, ajaxReturn);
          (I changed "html_GetElement(xxx).value" to use the $v and $s functions, html_GetElement is ancient, you should use $s and $v)
          • 2. Re: Master detail form issue retrieving service price automatically
            Tonito99
            Hi Tom,

            I applied these changes on page HTML Header, but now it's not returning nothing.
            f07_ (price column) is empty.


            <script type="text/javascript">

            function GetServicePrice(pThis)
            {       
            var ajaxRequest = new htmldb_Get(null, $v('pFlowId'), 'APPLICATION_PROCESS=getPrice', 0);
            var ajaxReturn = ajaxRequest.get();
            $s('f07_'+vRow, ajaxReturn);

            }
            </script>


            Any other suggestion?

            Regards,

            Edited by: Tonito99 on Mar 8, 2013 3:32 PM
            • 3. Re: Master detail form issue retrieving service price automatically
              VC
              Tonito99 wrote:
              Hi Tom,

              I applied these changes on page HTML Header, but now it's not returning nothing.
              f07_ (price column) is empty.


              <script type="text/javascript">

              function GetServicePrice(pThis)
              {       
              var ajaxRequest = new htmldb_Get(null, $v('pFlowId'), 'APPLICATION_PROCESS=getPrice', 0);
              var ajaxReturn = ajaxRequest.get();
              $s('f07_'+vRow, ajaxReturn);

              }
              </script>


              Any other suggestion?

              Regards,

              Edited by: Tonito99 on Mar 8, 2013 3:32 PM
              If you are on apex 4.2 why are you still using the legacy/undocumented methods?

              You should use new javascript API apex.server.process
              apex.server.process ( "getPrice", {
               success: function( pData ) { $s('f07_'+vRow, pData);}
                } );
              • 4. Re: Master detail form issue retrieving service price automatically
                LionHeart
                VC,

                I have a similar problem, it's giving me headache...

                Where do I put the code that you provided???

                On HTML Header or where????....

                Thank you in advance.
                • 5. Re: Master detail form issue retrieving service price automatically
                  VC
                  Hekuran wrote:
                  VC,

                  I have a similar problem, it's giving me headache...

                  Where do I put the code that you provided???

                  On HTML Header or where????....

                  Thank you in advance.
                  please do not deviate the OP's problem here...you should raise a new thread as you have a different problem.

                  And include enough information when asking a question ..such as apex version and detail explanation.

                  Also consult the documentation first (Incorporating JavaScript Utilizing the JavaScript Attribute) http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35125/bldapp_js.htm#BABHCJGG
                  • 6. Re: Master detail form issue retrieving service price automatically
                    Tonito99
                    Hi VC,

                    Sorry for bothering you, I'm quite new in apex.

                    I copied apex.server.process api provided by you on page HTML Header, it's not returning any value.


                    apex.server.process ( "getPrice", {
                    success: function( pData ) { $s('f07_'+vRow, pData);}
                    } );

                    If you can advice me further?

                    Regards,
                    • 7. Re: Master detail form issue retrieving service price automatically
                      VC
                      Tonito99 wrote:
                      Hi VC,

                      Sorry for bothering you, I'm quite new in apex.

                      I copied apex.server.process api provided by you on page HTML Header, it's not returning any value.
                      Why? you should copy that into JavaScript attribute under edit page
                      >
                      apex.server.process ( "getPrice", {
                      success: function( pData ) { $s('f07_'+vRow, pData);}
                      } );

                      If you can advice me further?
                      you can debug javascript by adding an alert
                       apex.server.process ( "getPrice", {
                        success: function( pData ) { alert(pData);
                            $s('f07_'+vRow, pData);
                      }
                         } );
                      and what does your plsql code look like for getPrice
                      • 8. Re: Master detail form issue retrieving service price automatically
                        Tonito99
                        Hi,

                        After I did necessary changes, javascript debug returns word: "undefined".


                        Below is plsql code:

                        declare

                        v_price service.price%type;

                        begin
                        select price into v_price
                        from service
                        where service_no = 1; --to be changed with correct parameter
                        htp.p(v_price);
                        exception when others then htp.p('An error occurred retrieving the PRICE');
                        end;

                        Regards,
                        • 9. Re: Master detail form issue retrieving service price automatically
                          Tonito99
                          I hard coded

                          $s('f07_'+vRow, pData); to

                          $s('f07_0001', pData);

                          On debug console now I see:

                          POST http://localhost:8080/apex/wwv_flow.show 404 (Not found) jquery-1.7.1.js:8102
                          send jquery-1.7.1.js:8102
                          jQuery.extend.ajax jquery-1.7.1.js:7580
                          _call server.js:384
                          server.process server.js:191
                          (anonymous function) f:231
                          fire jquery-1.7.1.js:1046
                          self.fireWith jquery-1.7.1.js:1164
                          jQuery.extend.ready jquery-1.7.1.js:435
                          DOMContentLoaded jquery-1.7.1.js:923

                          Regards,
                          • 10. Re: Master detail form issue retrieving service price automatically
                            VC
                            Tonito99 wrote:
                            Hi,

                            After I did necessary changes, javascript debug returns word: "undefined".


                            Below is plsql code:

                            declare

                            v_price service.price%type;

                            begin
                            select price into v_price
                            from service
                            where service_no = 1; --to be changed with correct parameter
                            htp.p(v_price);
                            exception when others then htp.p('An error occurred retrieving the PRICE');
                            end;

                            Regards,
                            change htp.p to htp.prn because htp.p adds new line char at the end

                            Can you reproduce the issue on apex.oracle.com
                            • 11. Re: Master detail form issue retrieving service price automatically
                              Tonito99
                              I'll do and come back to you with log in info.

                              Regards,
                              • 12. Re: Master detail form issue retrieving service price automatically
                                Tonito99
                                Hi VC,

                                I created my application on apex.oracle.com.

                                http://apex.oracle.com/pls/apex/f?p=4550:1:0:::::

                                Application 44905 - Demo-App

                                workspace: mpc
                                demo/demo

                                Reproduced case is page: 23-Master Detail

                                I appreciate your help.

                                Regards,

                                Edited by: Tonito99 on Mar 9, 2013 1:11 PM
                                • 13. Re: Master detail form issue retrieving service price automatically
                                  Tonito99
                                  Hi Tom,

                                  I fixed it based on your recommendation.
                                  Issue was variable vRow which during process I removed accidentally.

                                  This row:
                                  var vRow = pThis.id.substr(pThis.id.indexOf('_')+1);

                                  Thank you,
                                  Regards