3

I have an application item- APP_BRCODE (not a page item), if I access the value using &APP_BRCODE. I can retrieve the value, but I can't set the value using javasctipt. $s('APP_BRCODE',value) does not works

2 Answers 2

4

Javascript alone can only change the value of an item that has been rendered on the page - i.e. page items. To change the value of an application item requires a call to the database - either submitting the page or making an AJAX call. You can make an AJAX call from Javascript code something like this:

apex.server.process 
  ( "MY_PROCESS",
    { x01: my_var 
    },
    { success: function( pData ) {
               },
     dataType: "text"
    }
  );

This will set x01 to the value of variable my_var and call the AJAX callback (aka "on demand") PL/SQL process MY_PROCESS.

The PL/SQL process can then set the application item:

:APP_ITEM := apex_application.g_x01;

Seems like a lot of work? Maybe. Without knowing why you want to set an application item from Javascript it's hard to say whether this is worthwhile. You could just set a hidden page item instead?

0
0

I end up seeing your reply when I'm looking for solution for the same context.

In Dynamic Actions,

apex.server.process
  ( "upload_ajax_process",

    { x01: this.browserEvent.originalEvent.detail.serverId
    },

    { success: function( pData ) {
               },
     dataType: "text"
    }
  );

In Processing, created call back function "upload_ajax_process" as below. The insert statement inserts the value correctly in the table, however the page display item P12_DOCUMENTURL is not showing the value. What I'm missing here?

begin
:P12_DOCUMENTURL := apex_application.g_x01;

insert into tbl_bs_commentsdoc (commentsdocid, documenturl)
values (seq_commentsdoc_commentsdocid.nextval, apex_application.g_x01);

end;

Not the answer you're looking for? Browse other questions tagged or ask your own question.