Search code examples
oracle-apexoracle-apex-5

How open modal pages conditionally?


I am using Oracle APEX 21.1. I have a table visits with a column visit_type. visit_type has only values 1 or 2. There are 2 dialog pages(1 and 2). I need to create a query that returns a link that opens page 1 when visit_type = 1 and opens page 2 when visit_type = 2. Should I select a string with <a href=""</a> tag or use APEX_PAGE.GET_URL API. Either way, kindly, give me an example.


Solution

  • Here is a typical format

      apex_string.format(
          '<a class="t-Button t-Button--hot t-Button--simple t-Button--stretch" href="%s">%s</a>'
        , apex_page.get_url
           (p_application => 'YOUR_APP'
           ,p_page        => t.visit_type
           ,p_items       => 'p'||t.visit_type||'_id'
           ,p_values      => t.visit_id
           )
        , 'Link text'
        ) as link_target
    

    Don't forget to not escape special characters in your column definition.