oracle-apexoracle-apex-18.2

Can I pass values to non-APEX static files?


Using APEX 18.2. I am listening to IG's grid model to set a net amount item of an invoice when specific changes happen to the model, using the following code:

(function($) {

 $(function() {
/*gRegionStaticId is the variable hodlds the IG that owns the model. */
  $(gRegionStaticId).on("interactivegridviewmodelcreate", function(event, ui) {
   var sid,
    model = ui.model;
   console.log('modelCreated');
   if (ui.viewId === "grid") {
    sid = model.subscribe({
     onChange: function(type, change) {
      if (type !== "set" && type !== "move" && type !== "metaChange" && type !== "insert" && type !== "clearChanges") {
  /*"pFlowStepId" is page's number. gSetNetAmount is the global variable holds the function to set net amount.*/
$s("P" + $v('pFlowStepId') + "_NET_AMOUNT", gSetNetAmount().toString());
          //alert('&APP_PAGE_ID');
      }
     }
    });
   }
  });
 });

})(apex.jQuery);

The code is stored in a static file that's called from the File URLs page attribute. gRegionStaticId and gSetNetMaount are global variables defined and assigned the static id of the IG that owns the model I am listening to and the function that calculates the net amount respectively at Function and global variables page attribute . I am doing so to use the code dynamically instead of duplicating it in multiple pages. The problem(I think) is that File URL attribute that loads the static file with the above code runs before setting the global variables at Function and global variables page attribute.

Is there a way to set the variables before the static file loaded? Or maybe pass values to the static files?


Solution

  • I solved it. I gave the region a css class and referred it in the static file as I mentioned above and regarding the net amount calculation function.

    I assigned the variable gSetNetAmount the function name gSetNetAmount = itemTotal; in Execute when page loads page attribute after declaring the variable in Function and global variables declaration page attribute. And it worked very well. Thanks @Salim.