13

I'm using Oracle APEX but am unsure how to access the following variables from an external javascript file that may be located on the app server or stored in Shared Components -> Static Files.

:APP_ID
:APP_PAGE_ID
:APP_SESSION

How can I reference the values for each of the above from javascript (stored as a Static File)?

2 Answers 2

24

These values get rendered on the page as hidden items like this:

<input type="hidden" name="p_flow_id" value="4000" id="pFlowId" />
<input type="hidden" name="p_flow_step_id" value="4150" id="pFlowStepId" />
<input type="hidden" name="p_instance" value="6528421540413702" id="pInstance" />

so you can reference them as:

$v('pFlowId') // APP_ID
$v('pFlowStepId') // APP_PAGE_ID
$v('pInstance') // SESSION

It's a pity they aren't named the same as the session state!

Sign up to request clarification or add additional context in comments.

3 Comments

What about APP_USER?
@6190 APP_USER isn't, you would need to create your own hidden page item to hold that.
@6055 do var app_user = '&APP_USER.'; in the page detail / section "JavaScript" / textarea "Function and Global Variable Declaration". You can then use it elsewhere in the page.
7

Since APEX 5 you can also use apex.item instead of $v, as described here:

apex.item('pFlowId').getValue() // APP_ID
apex.item('pFlowStepId').getValue() // APP_PAGE_ID
apex.item('pInstance').getValue() // APP_SESSION

Both $v and apex.item require that the "apex" namespace has already been loaded at the time you try to access the values. If you ever need to access them before that, you can also use JavaScript only instead:

document.getElementById('pFlowId').value; // APP_ID
document.getElementById('pFlowStepId').value; // APP_PAGE_ID
document.getElementById('pInstance').value; // APP_SESSION

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.