Oracle Apex Dynamic Page Item Help

By
Ben Lee
December 21, 2015

I’m Ben Lee I’m into report development, data integration and data modelling. In this blog I explain how I helped a customer manage their own help text.
Recently I had the scenario where a customer wanted to be able to manage their own help text for a page in an application I was building for them. My requirements for a solution were quite simple; it needed to work with Apex’s built in help text functionality and templates. My goal is always to ensure whatever I build can survive an Apex environment upgrade. Basically, keep it simple and you will avoid problems in the future, plus you get the added bonus of getting any new generic functionality from every upgrade without rework. The information I found on this topic was surprising sparse and the options provided that helpful few.
Here’s the solution I came up with to solve my problem.
Create a table that users can maintain with the desired help text.
[code]CREATE TABLE HELP_TEXT
(HELP_TEXT_ID NUMBER,
PAGE_ITEM_NAME VARCHAR2(50),
ITEM_NAME VARCHAR2(50),
PAGE_ITEM_HELP VARCHAR2(400),
CONSTRAINT HELP_TEXT_PK PRIMARY KEY (HELP_TEXT_ID),
CONSTRAINT HELP_TEXT_UK UNIQUE (PAGE_ITEM_NAME));
[/code]Create a sequence for the primary key
[code]CREATE SEQUENCE HELP_TEXT_SEQ;
[/code]Now for the steps in Apex.

  1. Build a form in Apex to maintain the help. Use the wizards to make a maintenance screen, enough said on that
  2. Build your desired Apex Page.
  3. Copy the page from Step 2.
  4. Change all items on page from Step 3 to Text Fields.
  5. From Page built in Step 2 create a Page Process of type PL/SQL anonymous block, On Load – After Header. Then place the following code in the source.
    [code]BEGIN
    FOR C1REC IN (SELECT * FROM HELP_TEXT)
    LOOP
    APEX_UTIL.SET_SESSION_STATE(C1REC.PAGE_ITEM_NAME, C1REC.PAGE_ITEM_HELP);
    END LOOP;
    END;
    [/code]
apex_page_item_help_page_process
  1. On any items that require dynamic help text.
  2. Insert a row into the HELP_TEXT Table. For example, if your page has an item called P1_NOTE and you have copied that page to a new Page 2 such that you now have a P2_NOTE. In the HELP_TEXT table PAGE_ITEM_NAME should be set to P2_NOTE for that time. The help text can be set at any message.
apex_page_item_help_text
  1. On P1_NOTE help text use the text substitution &P2_NOTE. for the source of the help text
apex_page_item_help

That’s it, your page items will now have a standard template driven help link with dynamic content whenever the PAGE_ITEM_HELP value in the table is not null or empty.

apex_page_item_help_text_message


Thanks, Ben.
All the code, all the fun – Ben

Ben writes blogs on the technical side of BI, the code, all the code and not much other than the code.

Connect with Ben on LinkedIn or read some of his other blogs here.

Copyright © 2019 OptimalBI LTD.