How to access Oracle Apex variables from Javascript?

若如初见. 提交于 2019-12-03 11:16:54

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!

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!