- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2025 09:32 PM
Hi All,
How to retrieve all users in the caller field who belong to the same department as the logged in user?
I have written below script include but it's doesn't fetch correct data
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2025 09:43 PM
you can use something like this in advanced ref qualifier
no script include required
javascript: 'department=' + gs.getUser().getDepartmentID();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2025 09:43 PM
you can use something like this in advanced ref qualifier
no script include required
javascript: 'department=' + gs.getUser().getDepartmentID();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2025 10:03 PM
The logic is working as expected, Cloud pls tell me why script include is nit working?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2025 10:37 PM
you should update script as this and use array to hold user sysIds and then return the query
departmentName: function() {
gs.info("department" + gs.getUserID());
var arr = [];
var user_dep = new GlideRecord("sys_user");
user_dep.addQuery("sys_id", gs.getUserID());
user_dep.query();
while (user_dep.next()) {
arr.push(user_dep.getUniqueValue());
}
return 'sys_idIN' + arr.toString();
},
ref qualifier as this in that field
javascript: new DepatmentNameUtil().getDepartmentName();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-06-2025 10:55 PM
Hi Ankur,
It's displaying only logged in user record, total 35 records are there in same dapartment