Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to sync parent to child incident Assigned to and assignment group

R Charan C
Tera Expert

I have a requirement to sync child incidents (assigned to filed) to parent incident. so every time, I update 'assigned to' in parent incident.

I wrote this below, NOT WORKING. Any help ?

Async, 
Update,

condition: Assigned to changes.

 

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

    var grIncident = new GlideRecord("incident");
    grIncident.addActiveQuery();
    grIncident.addQuery("parent_incident", current.sys_id+"");
    grIncident.setValue("assignment_group", current.assignment_group+"");
    grIncident.setValue("assigned_to", current.assigned_to+""); // In case you want assinment group emty then comment this and uncomment below line
    // grIncident.setValue("assigned_to", "");
    grIncident.updateMultiple();

})(current, previous);
1 ACCEPTED SOLUTION

Found out the issue, I was looking at the wrong table .
I made BR changes to extended table and looking for Child incidents on Incident table. That's the mistake I made. This should be good.
Thanks for looking in to it. @Bert_c1 

View solution in original post

7 REPLIES 7

jonsan09
Giga Sage
Giga Sage

You could try something like this:

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

    var parentInc = current.sys_id;

    var childIncs = new GlideRecord('incident');
    childIncs.addQuery();
    childIncs.addActiveQuery("parent_incident", parentInc);
    childIncs.query();
    while (childIncs.next()) {
        childIncs.assignment_group = current.assignment_group;
        childIncs.assigned_to = current.assigned_to;
        childINcs.update();
    }

})(current, previous);

Not working, I'm doing this on a extended incident table.

Bert_c1
Kilo Patron

Hi R Charan C,

 

I tested your script, and got expected results. Assigned to and assignment group changed on the incidents with 'parent_incident' to what was set on the "parent" incident. I don't understand why yours doesn't work. Maybe try the above suggested changes.

Not working. Is this because we have extended table and the script is on extended incident table ?