Skip to Main Content

Highlight IR row based on APP_USER

Here is how you can highlight interactive report rows if column value is same as login user name. I did get idea for this article from this OTN forum post.

First create interactive report. In this example rows where manager name equals APP_USER value are highlighted.

I have used following query joining EMP and DEPT tables for interactive report:

SELECT e1.empno
    ,e1.ename
    ,e1.job
    ,e2.ename AS mgr -- Dynamic action use this column alias
    ,e1.hiredate
    ,e1.sal
    ,e1.comm
    ,d.dname
    ,d.loc
FROM emp e1
LEFT JOIN emp e2
    ON e1.mgr = e2.empno
JOIN dept d ON e1.deptno = d.deptno

Create dynamic action:

  • Name: Highlight based on APP_USER
  • Event: After Refresh
  • Selection Type: Region
  • Region: {select your report region}
  • Condition: No Condition
  • Action: Execute JavaScript code
  • Fire On Page Load: True
  • Code:
    this.affectedElements.find('table.apexir_WORKSHEET_DATA td[headers="MGR"]').each(function(i){
     var lThis=$(this);
     if(lThis.text()=="&APP_USER."){
      lThis.parent().children().css({"background-color":"#55A955"});
     }
    });
    
  • Selection Type: Region
  • Region: {select your report region}

Note! You need modify dynamic action JavaScript part td[headers="MGR"] according your report column alias.

See working example.

When you loging to example application use username BLAKE, JONES or KING to see highlight in action.

Comments

  • Jari Laine 23 Apr 2017

    Hi andrew_bis,

    Yes, example don't work on APEX 5.x without changes.
    You need change dynamic action JavaScript to be e.g.

    this.affectedElements.find('td[headers="MGR"]').each(function(i){
    var lThis=$(this);
    if(lThis.text()=="&APP_USER."){
      lThis.parent().children().css({"background-color":"#55A955"});
    }
    });

    Regards,
    Jari

  • andrew_bis 20 Apr 2017

    The highlighting doesn't seem to work, even in your demo. I'm using the latest version of Chrome.