How to Automatically Close Child Incidents When Parent Incident is Closed via UI Action

vaishali231
Tera Contributor

Hi Community,

I have a requirement where, when a parent Incident is closed using a UI Action, the system should automatically:

Close all associated child Incidents (those with the parent value set).

Update each child Incident with a work note, similar to the one entered in the parent.

Could someone guide me on how to approach this?
Should this logic be added in the UI Action script of the parent? And how can I best loop through and update all child records with the parent's work note?

Any sample scripts or best practices would be appreciated.
Thanks in advance

14 REPLIES 14

GlideFather
Tera Patron

Hi @vaishali231,

 

I would approach this via BR, you can get inspiration from OOTB: Update Child Incidents

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Chai Maddula
Giga Guru

Hi @vaishali231 

 

I suggest go with a flow designer to do this to avoid scripting. there is an example vide how to update child -> parent for another table. you can adopt the same idea

 

https://www.youtube.com/watch?v=LK5XnFFhH-A

 

If my response solves your query, please marked helpful by selecting Accept as Solution and Helpful

nemamuskan
Tera Contributor

Hello @vaishali231,

 

You can create "after" "update" Business Rule for this on incident table with the condition when state Changes to Closed and write following script within it:

 

(function executeRule(current, previous /*null when async*/) {

    var gr=GlideRecord("incident");
    gr.addQuery("parent_incident",current.sys_id);
    gr.query();
    while(gr.next())
    {
        gs.log(gr.number);
        gr.state=7;
        gr.close_code=current.close_code; //mandatory field to close incident
        gr.close_notes=current.close_notes;  ////mandatory field to close incident
        gr.work_notes=current.work_notes;
        gr.update();
    }

})(current, previous);
 
Please refer to the Screenshots attached here.
Please mark this as helpful if it helps.
 
Thanks!!

how to do using only ui action ??