Show only users reporting to manager selected.

vahini
Giga Guru

Requirement : 

There are two fields referenced to user table 

Field 1 : Requested for ( manager is selected in this field )  and

Field 2 : What is the name of the employee ( referenced to user table ) 

 

When manager name is selected in field1 then all users on user table with manager = person selected in field should be visible in field3 .

 

To achieve this use  reference qualifier on field2  and put this code in it.

 

javascript:"u_resource_type=Employee^manager="+current.variables.requested_for;

 

to get this query, go to user table, filter resource type = employee and manager is Michael Jakson , query looks like below

u_resource_type=Employee^manager=Michael Jakson 

 

then remove the manager name and put everything in quotes + current.varaibles. field1 backend name.

 

should look like below :

javascript: "u_resource_type=Employee^manager="+ current.variables.requested_for;

 

vahini_2-1736223561612.png

 

 

 

 

 

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@vahini 

so what's your question?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

yuvarajkate
Giga Guru

To filter the What is the name of the employee field (Field 2) based on the selected manager in the Requested for field (Field 1), use the following reference qualifier in Field 2's configuration:

 

Set the Reference Qualifier:

  • Go to the Field 2 (What is the name of the employee) definition.
  • In the Reference Qualifier field, use this script:
 

 

javascript: "u_resource_type=Employee^manager=" + current.variables.requested_for;

 

How It Works:

  • current.variables.requested_for dynamically fetches the manager selected in Field 1 (Requested for).
  • The query filters users with u_resource_type=Employee and matches the selected manager, showing only employees under that manager.