Friday, February 1, 2013

APP_PAGE_ID=0 in OnDemandProcess

In APEX we have many Substitution Strings. One of these is :APP_PAGE_ID. Be careful with this String in an OnDemandProcess. I have called an OnDemandProcess by using JavaScript/AJAX and the result was, that :APP_PAGE_ID was always 0.
To solve this problem i have created an Application Item (AI_APP_PAGE_ID). This item will be filled every time a page is rendered in APEX.

Due some good tips the problem can be solved by calling the OnDemandProcess with the correct full syntax from JavaScript.
var ajaxCall = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=IS_HANDLE_VALID', $v('pFlowStepId'));
With this call especially the last parameter $v('pFlowStepId') the pageId will be the actual ApexPageId where the Javascript is used.
Thanks to Peter and Roel for your tips.


  1. Quick Question: how exactly did you call the Application Process? Did you pass the Page-Id there?

  2. i called the process by javascript like

    var ajaxCall = new htmldb_Get(null,html_GetElement('pFlowId').value,

  3. Oliver, you could try to specify the actual Page-Id instead of the 0 in your example.

    See this Definition: function htmldb_Get(obj,flow,req,page,instance,proc,queryString) {

  4. When you call it that way, you specify it runs on Page 0 (the last parameter).
    What happens when you do:
    var ajaxCall = new htmldb_Get(null,$v('pFlowId'),'APPLICATION_PROCESS=IS_HANDLE_VALID', $v('pFlowStepId'));

  5. ok, do you have a link to the full definition of htmldb_get?

  6. Big thanks for your Tips.

    Yes Roel, with your example the Variable APP_PAGE_ID is now set to the correct page ID even when the Process is called from JavaScript.

  7. To get the full definition of htmldb_Get (as posted above) you simply have to look into the apex-javascript file (part of your APEX Installation, you can find it in images/javascript).

  8. Why is this javascript function not part of the official API?

  9. What makes you think it is not official?

    It is just not mentioned in the Documentation ;-)

  10. In my personal documentation, I've found a url ( pointing to some old APEX application, if I'm not mistaken from Carl Backstrom, explaining the usage and parameters of htmldb_Get.

    Maybe this can help you out.

    1. Thanks for your tip. That documentation is what i searched for.

  11. Thank you very much for this article. It was very helpful since I had the same matter. Thanks again.