Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Filtro

LarissaR4486026
Tera Contributor

I need to create a filter that takes the logged-in user in the variable set (it will always be a manager) and only displays users who have the logged-in user as their manager in the employee name field. The employee name field is a reference type for the sys_user table.

2 ACCEPTED SOLUTIONS

SP22
Giga Sage

Hello @LarissaR4486026,

Option 1: 
If this variable is reused across many items, move the logic into a Script Include so you can maintain it in one place.

Script Include (server‑side, not client‑callable):

var DirectReportsUtil = Class.create();
DirectReportsUtil.prototype = {
    initialize: function () {},

    getDirectReportsQuery: function () {
        // Add any additional constraints here
        return 'manager=' + gs.getUserID() + '^active=true';
    },

    type: 'DirectReportsUtil'
};

 

On the variable, set Reference qualifier to Advanced and use:

// Use a JavaScript expression to invoke the Script Include
answer = new DirectReportsUtil().getDirectReportsQuery();

 

Option 2: 

Use this when the variable is a reference to sys_user.

  1. Open your variable (inside the variable set).
  2. Set:
    • Type: Reference
    • Reference: sys_user
    • Reference qualifier: Advanced
  3. In Advanced reference qualifier (script) paste:
    // Returns only the direct reports of the logged-in user
    // (OPTIONAL) appends active=true to avoid inactive users in the list
    answer = 'manager=' + gs.getUserID() + '^active=true';​

    That’s it. The reference field will now only display users whose manager equals the current (logged‑in) user.

If this helped to answer your query, please mark it helpful & accept the solution.

Thanks
Santosh.p

 

 

View solution in original post

Raghav Sharma24
Giga Patron

I believe you have already achieved the loggedin user part so for employee part add the below reference qualifier advanced condition of employee.

 

javascript:”manager=“+current.variables.requested_for; 

// replace &colon with “:” and check the variable name having manager and replace it for requested_for


Please mark the answer correct/helpful accordingly.

 

View solution in original post

2 REPLIES 2

SP22
Giga Sage

Hello @LarissaR4486026,

Option 1: 
If this variable is reused across many items, move the logic into a Script Include so you can maintain it in one place.

Script Include (server‑side, not client‑callable):

var DirectReportsUtil = Class.create();
DirectReportsUtil.prototype = {
    initialize: function () {},

    getDirectReportsQuery: function () {
        // Add any additional constraints here
        return 'manager=' + gs.getUserID() + '^active=true';
    },

    type: 'DirectReportsUtil'
};

 

On the variable, set Reference qualifier to Advanced and use:

// Use a JavaScript expression to invoke the Script Include
answer = new DirectReportsUtil().getDirectReportsQuery();

 

Option 2: 

Use this when the variable is a reference to sys_user.

  1. Open your variable (inside the variable set).
  2. Set:
    • Type: Reference
    • Reference: sys_user
    • Reference qualifier: Advanced
  3. In Advanced reference qualifier (script) paste:
    // Returns only the direct reports of the logged-in user
    // (OPTIONAL) appends active=true to avoid inactive users in the list
    answer = 'manager=' + gs.getUserID() + '^active=true';​

    That’s it. The reference field will now only display users whose manager equals the current (logged‑in) user.

If this helped to answer your query, please mark it helpful & accept the solution.

Thanks
Santosh.p

 

 

Raghav Sharma24
Giga Patron

I believe you have already achieved the loggedin user part so for employee part add the below reference qualifier advanced condition of employee.

 

javascript:”manager=“+current.variables.requested_for; 

// replace &colon with “:” and check the variable name having manager and replace it for requested_for


Please mark the answer correct/helpful accordingly.