reference qualifier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 04:21 AM
Hi experts,
We have 'requested for' variable on record producer and it should show users record based on logged in user.
1. if the logged in user is a manager, we need show only their direct reportees.
2. if the logged in user is HR, we need to show all users
How can we achieve this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 04:37 AM
Hi @si21
For this you can use script include in your reference qualifier like javascript: new yourscriptincludename().methodname();
In your script include, check if the logged-in user is the manager?
If yes return all the users where the manager is logged-in user
else
return all users
Please mark helpful if this resolves your query.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 05:10 AM
Hi @si21
You will need a Script Include and a reference qualifier for this. Refer https://www.servicenow.com/community/developer-forum/script-include-to-see-logged-in-user-is-an-mana... to get the reference for script include.
javascript: new yourscriptincludename().methodname(); syntax should be used for reference qualifier.
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2024 06:22 AM - edited 02-13-2024 06:22 AM
Hi @si21 ,
Reference qualifier :javascript:new scriptincludename().scriptIncludeFunctionName()
Below script Include Code:
var mgr = gs.getUser().getRecord().getValue('manager');
var a = new GlideRecord('sys_user');
a.addQuery('manager', mgr );
a.query();
var users = [];
while (a.next()) {
users.push(a.getUniqueValue());
}
return 'sys_idIN' + users.toString();
Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand