1
votes

I have an oracle apex tabular form, Which selects data from a temporary table GL_TEMP . The data in the temporary table inserts in an "ondemand proecess" ajax call, which is performed in a button click . After the data inserted the tabular form refresh call is performed using the code

 $('#TBN').trigger('apexrefresh');  

where TBN is the static id of the tabular form. Prtial page refresh option is set YES for this tabular form. But the above javascript refresh trigger shows some anomalous behaviour. Some times the tabular form refresh works in the first button click, some times it takes two or three or even more button clicks to refresh the tabular form and load the data. I have verified that there is no issue with data insertion in the temporary table. I have tried the code

apex.event.trigger( "#TBN ", "apexrefresh" );

also, but no change in result. Only the tabular form refrshing action shows some anomalous behaviour. oracle apex version 5.0.3. My ondemand process call is here

 var $wP;

 setTimeout(function(){
        $wP = apex.widget.waitPopup();
 }, 10);

 apex.server.process("INSERT_GL_NOTICE", {

         x01: $('#P390_HEAD').val(),
         x02: $('#P390_MAILHEAD').val(),
         x03: $('#P390_INTDT').val(),
         x04: $('#P390_TRANSDT').val(),  
         x05: $('#P390_FROMDT').val(),
         x06: $('#P390_TODT').val(),
         x07: $('#P390_INTERVAL_MM').val(),
         x08: $('#P390_EXCLUDE_SUBSIDY').val()

         },{type: "GET", dataType: "json", success: function( json ) {

                  $wP.remove();
                  $('#TBN').trigger('apexrefresh'); // TBN- id for tabular form
                  if(json.MSG){
                       alert(json.MSG);
                  }


           },    
     })

Here is my on demand process

declare
msg_stat varchar2(100);
msg varchar2(250);
cnt number;
cnt1 number;
transdt date;
mhead varchar2(8);
intdt date;
cd varchar2(8);
fdt date;
tdt date;
gen_id varchar2(50);
brcd varchar2(5):=apex_util.get_session_state('APP_BRCODE');
intr_mm number;
exc_sub char(1);
L_JSON_STR varchar2(4000);

begin

  cd:=apex_application.g_x01;
  mhead:=apex_application.g_x02;
  intdt:=apex_application.g_x03;
  transdt:=NVL(apex_application.g_x04,SYSDATE);
  fdt:=apex_application.g_x05;
  tdt:=apex_application.g_x06;
  intr_mm:=nvl(apex_application.g_x07,2);
  exc_sub:=nvl(apex_application.g_x08,'N');

  transdt:=trunc(sysdate);

  if mhead is null then
      msg:='Mail Head should be Entered ';
      Raise_application_error(-20001,msg);
  end if;

  if intdt is null then
     msg:='Interest Calculation Date Not Entered ';
      Raise_application_error(-20001,msg);
  end if;

  if tdt>=intdt then
     msg:='Int Date should be greater or Equal to To Date';
    intdt:=sysdate+10;
  end if;

  APEX_INSERT_GLNOTICE_TEMP(brcd,cd,fdt,tdt,intdt,mhead,intr_mm,exc_sub,msg_stat,gen_id);
  apex_util.set_session_state('APP_GEN_ID',gen_id);
  L_JSON_STR:='{
   "MSG":"'||msg_stat||'"
  }';
  SYS.HTP.P(L_JSON_STR);
  return; 

exception when others then  
    apex_util.set_session_state('APP_GEN_ID',null);
   L_JSON_STR:='{
     "MSG":"'||msg||'"
  }';
  SYS.HTP.P(L_JSON_STR);
  return; 

end;

And this is my tabular form query

select 
"BRCODE",
"CODE",
"REPT_GEN_ID",
"ACCNO",
"LOANDT",
"LNAME"
from "GL_TEMP"
where REPT_GEN_ID=apex_util.get_session_state('APP_GEN_ID')
1
In your sql there is a comma after the last column, but I think this is just a wrong in copy and past and get_session_state should be not necessary if app_gen_id is an item because you are putting the value in session in your on a demand process. There is some time that i not execute a sql, but REPT_GEN_ID = NULL cause some problem? if yes, you need to rewrite this section to prevent any error.romeuBraga
it was a pasting error. I tried to put the 'APP_GEN_ID' value in session item as well as in a page itemNidheesh
In that null case, I just want to refresh region and no data need to be displayedNidheesh

1 Answers

1
votes

How do you call this on demand process?

If this on demand process is working in your tabular form, maybe the problem is just the delay time to do these operations before to refresh the region.

I think you are using apex.server.process to call this process. In this case, try to show to user something to they know that application are doing something https://docs.oracle.com/database/apex-18.1/AEXJS/apex.widget.html

var $wP;

apex.server.process("INSERT_GL_NOTICE", {
     x01: $('#P390_HEAD').val(),
     x02: $('#P390_MAILHEAD').val(),
     x03: $('#P390_INTDT').val(),
     x04: $('#P390_TRANSDT').val(),  
     x05: $('#P390_FROMDT').val(),
     x06: $('#P390_TODT').val(),
     x07: $('#P390_INTERVAL_MM').val(),
     x08: $('#P390_EXCLUDE_SUBSIDY').val()

     },{type: "GET", dataType: "json", 

        beforeSend: function() {
           $wp = apex.widget.waitPopup();
        },

        success: function( json ) {
              $wP.remove();
              $('#TBN').trigger('apexrefresh'); // TBN- id for tabular form
              if(json.MSG){
                   alert(json.MSG);
              }
       },    
 })