When we define "Help Text" for page items, then APEX displays a little "?" icon next to the page item. For Interactive Grids (IG), help icon is displayed when users click on the column header. When we click help icon, then we can see the help text defined for the item. In some cases, this may not be very handy for users. Let's consider a user registration form in your website. Users might be coming for the first time to your website and users may not be aware that they must click on the little icon to see the help text. In such cases, displaying help information proactively will be helpful for users.
In this blogpost, I am going to explain a simple approach to proactively display item's help text to users.
Summary of this implementation:
- Create "Help" region which displays help text based on page Item Name or IG column Static ID.
- When user focuses on any field, then get the Item Name or IG column Static ID. Set these values into hidden page items and refresh the "Help" region.
CREATE OR REPLACE FUNCTION get_item_help( p_item_name IN VARCHAR2 ,p_page_id IN NUMBER DEFAULT NULL ,p_application_id IN NUMBER DEFAULT NULL )RETURN VARCHAR2 IS l_help_text apex_application_page_items.item_help_text%TYPE; BEGIN SELECT item_help_text INTO l_help_text FROM apex_application_page_items WHERE item_name = p_item_name AND page_id = coalesce( p_page_id ,nv( 'APP_PAGE_ID' ) ) AND application_id = coalesce( p_application_id ,nv( 'APP_ID' ) ); RETURN l_help_text; EXCEPTION WHEN no_data_found THEN RETURN 'Invalid Item Name ' || p_item_name; END get_item_help;
CREATE OR REPLACE FUNCTION get_ig_col_help( p_col_static_id IN VARCHAR2 ,p_reg_static_id IN VARCHAR2 ,p_page_id IN NUMBER DEFAULT NULL ,p_application_id IN NUMBER DEFAULT NULL )RETURN VARCHAR2 IS l_help_text apex_appl_page_ig_columns.help_text%TYPE; BEGIN SELECT cols.help_text INTO l_help_text FROM apex_appl_page_ig_columns cols JOIN apex_application_page_regions reg ON(reg.region_id = cols.region_id) WHERE cols.static_id = p_col_static_id AND reg.static_id = p_reg_static_id AND cols.page_id = coalesce( p_page_id ,nv( 'APP_PAGE_ID' ) ) AND cols.application_id = coalesce( p_application_id ,nv( 'APP_ID' ) ); RETURN l_help_text; EXCEPTION WHEN no_data_found THEN RETURN 'Invalid Input. Column Static ID ' || p_col_static_id || ', Region Static ID ' || p_reg_static_id || ' do not exists.'; END get_ig_col_help;
- Title: Help
- Type: Classic Report
- Source:
- Type: SQL Query
- SQL Query: As shown below
- Page Items to Submit: P33_ITEM_NAME,P33_REG_STATIC_ID,P33_COL_STATIC_ID
- Layout:
- Position: Right Column
- Attributes:
- Pagination:
- Type: No Pagination (Show All Rows)
- Messages:
- When No Data Found: Please focus on any input field to see the help text defined for the field.
SELECT get_item_help(:P33_ITEM_NAME) help_text FROM DUAL WHERE :P33_ITEM_NAME IS NOT NULL UNION ALL SELECT get_ig_col_help(:P33_COL_STATIC_ID,:P33_REG_STATIC_ID) help_text FROM DUAL WHERE :P33_COL_STATIC_ID IS NOT NULL
SELECT item_help_text help_text FROM apex_application_page_items WHERE item_name = :P33_ITEM_NAME AND page_id = :APP_PAGE_ID AND application_id = :APP_ID UNION ALL SELECT cols.help_text FROM apex_appl_page_ig_columns cols JOIN apex_application_page_regions reg ON(reg.region_id = cols.region_id) WHERE cols.static_id = :P33_COL_STATIC_ID AND reg.static_id = :P33_REG_STATIC_ID AND cols.page_id = :APP_PAGE_ID AND cols.application_id = :APP_ID
- P33_ITEM_NAME
- P33_REG_STATIC_ID
- P33_COL_STATIC_ID
- Name: Show Items Help Text
- When:
- Event: Get Focus
- Selection Type: Item(s)
- Item(s): P33_FIRST_NAME,P33_LAST_NAME,P33_GENDER,P33_PROFESSION,P33_HOBBIES,P33_DATE_OF_BIRTH
- Action: Execute JavaScript Code
- Settings:
- Code: As shown below
apex.item("P33_ITEM_NAME").setValue($(this.triggeringElement).attr("id")); apex.item("P33_REG_STATIC_ID").setValue(""); apex.item("P33_COL_STATIC_ID").setValue("");
- Action: Refresh
- Affected Elements:
- Selection Type: Region
- Region: Help
- Name: Show IG Help Text
- When:
- Event: Get Focus
- Selection Type: Column(s)
- Region: Skills
- Column(s): SKILL_NAME,SKILL_LEVEL
- Action: Execute JavaScript Code
- Settings:
- Code: As shown below
apex.item("P33_COL_STATIC_ID").setValue($(this.triggeringElement).attr("id")); apex.item("P33_REG_STATIC_ID").setValue("skills"); apex.item("P33_ITEM_NAME").setValue("");
- Action: Refresh
- Affected Elements:
- Selection Type: Region
- Region: Help
- Action: Execute Server-side Code (Or "Execute PL/SQL Code" in older versions)
- Settings:
- Code: NULL;
- Items to Submit: P33_ITEM_NAME,P33_REG_STATIC_ID,P33_COL_STATIC_ID
- During the page load or right after page load, make an AJAX call and get all required help text from the server and store it as JSON object on client side. Use help text from JSON object every time when item focus changes.
- Or When user focuses on an item, then make an AJAX call and get item help text. Store the item help text on client side and use it from client side, if user focuses same item next time.
- Explore other fancy options to display help text instead of classic report.
Comments