0

I have a button that will process the selected rows in an Interactive Grid. It works fine. I want to add in an audit value to populate a column when this function is used. Where the LOCKED column is set to 1 I want the LOCKED_BY column to be set to :APP_USER.

How do I access the value from within the piece of Javascript? :APP_USER doesn't work nor does the $v() method as far as I can see.

Where am I going wrong?

var r = g.getSelectedRecords();
var v 

for(i = 0; i < r.length; i++) {
    v = g.model.getValue(r[i], 'WARN');
    if (v == '1') {
        g.model.setValue(r[i], 'LOCKED', '0');
    }
    else {
        g.model.setValue(r[i], 'LOCKED', '1');
        g.model.setValue(r[i], 'LOCKED_BY', $v('APP_USER')); //WANT TO SET THIS VALUE HERE
    }
}
1
  • Hi, I never do it but I would try to use :APP_USER as default value for an hidden item and then access the item as DOM element.
    – AlexMI
    Commented Feb 20, 2020 at 14:41

2 Answers 2

0

Javascript runs in the browser and so can only see items that are actually rendered on the page (i.e. page items, not application items). You could create a hidden page item (perhaps on page 0 if needed on all pages) for this purpose. However, if your Javascript is defined within APEX (not in a separate .js file) then you should be able to do this:

g.model.setValue(r[i], 'LOCKED_BY', '&APP_USER.'); 

&APP_USER. will be substituted with the value of APP_USER when the page is rendered.

-1

You can use apex.env.APP_USER.

More info in the Oracle Docs.

New contributor
user26079699 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
2

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