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.

*Update*
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.

12 comments:

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

    ReplyDelete
  2. i called the process by javascript like

    var ajaxCall = new htmldb_Get(null,html_GetElement('pFlowId').value,
    'APPLICATION_PROCESS=IS_HANDLE_VALID',0);

    ReplyDelete
  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) {

    ReplyDelete
  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'));

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

    ReplyDelete
  6. Big thanks for your Tips.

    @Roel
    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.

    ReplyDelete
  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).

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

    ReplyDelete
  9. What makes you think it is not official?

    It is just not mentioned in the Documentation ;-)

    ReplyDelete
  10. In my personal documentation, I've found a url (http://apex.oracle.com/pls/otn/f?p=11933:63) 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.

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

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

    ReplyDelete