Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Add Child of Incidents to Problem tickets

Cat
Giga Guru

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

12 REPLIES 12

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);

  

@Cat 

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! 🙏

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Dr Atul G- LNG
Tera Patron

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]

****************************************************************************************************************