- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 07:17 AM
hi,
i want to filter an incident out of a list if the incident has a parent universal request.
how do i do that in script?
many thanks.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 07:41 AM
var list = new GlideRecord("incident");
list.addEncodedQuery("universal_requestISEMPTY");
//list.setLimit(10);
list.query();
while (list.next()){
gs.info(list.getDisplayValue());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 07:22 AM
You can via list view without code
or
universal_requestISNOTEMPTY
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 07:41 AM
var list = new GlideRecord("incident");
list.addEncodedQuery("universal_requestISEMPTY");
//list.setLimit(10);
list.query();
while (list.next()){
gs.info(list.getDisplayValue());
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 08:02 AM - edited 02-24-2025 09:13 AM
Hi @Frank Cheung ,
This gets you the incidents that don't have an parent incident with universal request.
var inc = new GlideRecord('incident');
// Query all incidents
inc.query();
while (inc.next()) {
// Check if the incident has a parent
if (inc.parent) {
// Get the parent incident
var parentInc = new GlideRecord('incident');
parentInc.get(inc.parent);
if (parentInc.universal_request) {
gs.info("Incident " + inc.number + " has a parent incident (" + parentInc.number + ") with a universal_request.");
}
} else {
gs.info("Incident " + inc.number + " "+inc.sys_id);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2025 08:06 AM
this should be an easy task.
what's your challenge?
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