Search code examples
oracle-apex

How to dynamically display static text region in Oracle APEX based on whether currently selected person has an active pending request?


  • I have "textfield with autocomplete" (P2_EE) returning a list of values as "lastname, firstname [emp #]".
  • On P2_EE change, I parse out the emp #, pull data, and populate some readonly page items.
  • I want to conditionally display a static text block that warns if the selected person already has a pending request in the app. The block would need to hide or show as appropriate for any selection change in P2_EE.
  • I've tried doing this as an on-change dynamic action (running right after the on-change event listed above) which also has a server-side condition of "rows returned" based on sql (which checks if the emp # already has a pending request). Then I do a simple Show action on the static text region when true.

Unfortunately, the text block never displays.

I'd be grateful for any thoughts/suggestions.

Thank you.


Solution

  • The reason the text block never displays is the server-side condition. That is evaluated at page rendering time and never re-evaluated again.

    There are a couple of ways of solving this but the easiest is a creating a helper page item "P2_EE_SHOW_WARNING".

    In the on-change dynamic action, add an action of type "Execute Server-side code" to set this item to Y or N (make sure that "Items to return" has "P2_EE_SHOW_WARNING"). (This action does what the Server-side Condition in your question is supposed to do).

    Add a show action with client-side condition apex.items.P2_EE_SHOW_WARNING.getValue() === 'Y' and a hide action with apex.items.P2_EE_SHOW_WARNING.getValue() === 'N' .

    Let me know how this goes I can put together an example if needed.