Add Child of Incidents to Problem tickets
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi all,
We may attach a parent incident to a problem. Is there a way to add the list of child incidents to the problem? These are incidents where they are only attached to the parent - not the problem. Only the parent would be attached to the problem.
Thanks,
Cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you! I followed this, but it unfortunately didn't show any tickets in the new tab despite there being some attached to the parent.
I put it through CoPilot to see if it could help - it showed items but it listed every single incident if there was nothing in "first reported by" or if the first reported was a request. I'm not to great with javascript yet - do you have any ideas? The copilot script is below
(function refineQuery(current, parent) {
// Find all incidents associated to the Problem
var inc = new GlideRecord('incident');
inc.addQuery('problem_id', parent.sys_id);
inc.query();
var parentIncidents = [];
while (inc.next()) {
parentIncidents.push(inc.getUniqueValue());
}
// If no parent incidents, stop here
if (parentIncidents.length === 0)
return;
// Now find child incidents of ANY associated incident
var children = [];
var gr = new GlideRecord("incident");
gr.addQuery("parent", "IN", parentIncidents)
.addOrCondition("parent_incident", "IN", parentIncidents);
gr.query();
while (gr.next()) {
children.push(gr.getUniqueValue());
}
if (children.length > 0) {
current.addQuery('sys_id', 'IN', children);
}
})(current, parent);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I did share screenshots confirming approach worked fine for me
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Got it, mate. But I would still recommend trying to stick with the out-of-the-box (OOTB) approach.
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/dratulgrover [ Connect for 1-1 Session]
****************************************************************************************************************
