This discussion is archived
3 Replies Latest reply: Feb 4, 2013 1:01 PM by fac586 RSS

Syntax to make link column conditional based on IR column value?

988836 Newbie
Currently Being Moderated
Hi,

In 4.2, there's an option in the Link Column section of an IR to make it conditional, but it's not in the 4.2 docs. Even the screenshot in the 2-day manual (http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35122/build_app.htm#BCEJICGI) doesn't show it.

I'd like to make it conditional on the result of each value of a particular column of the IR report. For example, if the IR contains a column called USERNAME, how do I reference that column in the link column conditions like "Value of Item / Column in expression 1 is not null"?

Thanks,
Rich
  • 1. Re: Syntax to make link column conditional based on IR column value?
    Howard (... in Training) Pro
    Currently Being Moderated
    Rich,

    I have no ideas. Are you still looking for a solution. Did you search the forum with "report AND link AND condition"?

    You might look at {thread:id=359766}

    Regards,
    Howard
  • 2. Re: Syntax to make link column conditional based on IR column value?
    988836 Newbie
    Currently Being Moderated
    Hi Howard,

    I hadn't seen that particular post, but the idea of making the link its own column in the SQL had crossed my mind. In my case, it would complicate the SQL a bit as I'm reporting from a pipelined function. Definitely doable, but I was hoping this option would make the process cleaner and easier to maintain.

    For the record, that thread mentioned referencing the report item by enclosing it in hashes, in my case, #USERNAME#. I did try that, but every condition I tried came out false as the link column never displayed.

    Still not used to the debugger in 4.2 (I'm used to 3.1), but perhaps the value of #USERNAME# is in there somewhere?

    Thanks!
    Rich
  • 3. Re: Syntax to make link column conditional based on IR column value?
    fac586 Guru
    Currently Being Moderated
    RichApex wrote:

    In 4.2, there's an option in the Link Column section of an IR to make it conditional, but it's not in the 4.2 docs. Even the screenshot in the 2-day manual (http://docs.oracle.com/cd/E37097_01/doc/doc.42/e35122/build_app.htm#BCEJICGI) doesn't show it.

    I'd like to make it conditional on the result of each value of a particular column of the IR report. For example, if the IR contains a column called USERNAME, how do I reference that column in the link column conditions like "Value of Item / Column in expression 1 is not null"?
    For the record, that thread mentioned referencing the report item by enclosing it in hashes, in my case, #USERNAME#. I did try that, but every condition I tried came out false as the link column never displayed.
    Conditions on report columns apply to the entire column, not individual cells on a row-by-row basis. Neither can report column values be referenced in condition expressions.

    Unfortunately APEX provides no declarative way to do this at the column/report level. The easy way (and the only way in interactive reports) to do this is to violate the separation of concerns and generate the link conditionally in the query:
    ⋮
    case
      when field1 is null
      then
        '<a href="/* generated URL */">Foobar</a>'
      else
        field1
    end link_col 
    ⋮
    with the Display As column attribute for <tt>link_col</tt> set to Standard Report Column.

    The better (but more involved) way in standard reports that maintains the separation of concerns and keeps the HTML link structure out of the query is by implementing the logic via conditional column templates in a custom report template. In this situation the "other column" approach can be used to encapsulate any complex logic to avoid repetition in column condition PL/SQL expressions.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points