How to use the reference qual only for ITIL users

Jahnavi6
Kilo Expert

ITIL users should be able to search for users from all locations in "on behalf of" field, otherwise users specific to that location should be filtered in record producer/service portal.

So, for the field, I used the advance conditions, in the reference qualifier like this, but it is not working.

 

1 ACCEPTED SOLUTION

javascript: (gs.hasRole('itil') ? 'active=true' : 'location=' + gs.getUser().getLocation());

View solution in original post

15 REPLIES 15

Pranav Bhagat
Kilo Sage

Its better to use a script include and put your condition and call it in the ref qual.

 

Basically you query should be like

javascript:"location=" +gs.getUser().getLocation()^EQ;

Check this

https://www.servicenowguru.com/scripting/script-includes-scripting/advanced-reference-qualifier-script-include/

https://docs.servicenow.com/bundle/paris-platform-administration/page/script/server-scripting/concept/c_ReferenceQualifiers.html

https://community.servicenow.com/community?id=community_question&sys_id=6740c7a1db98dbc01dcaf3231f9619b7

 

Regards

Pranav

Example of script include for your use case

 

find_real_file.png

 

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

please update the ref qualifier as below

javascript: var query = ''; if(!gs.hasRole('itil')) query = 'location=' + gs.getUser().getLocation(); query;

Regards
Ankur

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

Willem
Giga Sage
Giga Sage

This should work:

javascript: (gs.hasRole('itil') ? '' : 'location=' + gs.getUser().getLocation());