Report Filtering based on user attribute
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 09:35 PM
Hello ServiceNow Community,
I have a requirement where I need to create the reports based on the conditions below. I am not familiar with how to enforce this logic, and hoping you can help resolve.
1. Filter by Tickets Opened By the user's manager. I have a requested by and requested for fields available.
Thank you in advance for your help.
Sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2025 07:11 AM
so when user ABC checks the report he/she should see tickers open by his/her manager?
you will have to use scripted filter condition
Script Include: client callable
function getRecords() {
var arr = [];
var manager = gs.getUser().getManagerID();
var gr = new GlideRecord("incident");
gr.addQuery("opened_by", manager);
gr.query();
while (gr.next()) {
arr.push(gr.getUniqueValue());
}
return arr.toString();
}
Then call in report filter condition as this
SysId [IS ONE OF] javascript: getRecords()
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
02-15-2025 04:35 PM - edited 02-15-2025 04:39 PM
My requirement is slightly different.
Basically, we need to pull a report on tickets where the requested by is the manager of the requested for user.
The report will be viewed by the leadership to understand the volume.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2025 09:45 PM
you can tweak the script I shared like this
function getRecords() {
var arr = [];
var gr = new GlideRecord("table");
gr.addEncodedQuery("requestedForISNOTEMPTY");
gr.query();
while (gr.next()) {
var manager = gr.requestedFor.manager;
var rec = new GlideRecord("table");
rec.addQuery('requestedBy', manager);
rec.query();
while (rec.next()) {
arr.push(rec.geUniqueValue());
}
}
return arr.toString();
}
I believe I have provided enough guidance and you can enhance the script further as per your requirement and based on your developer skills.
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