Not updating multiple child incidents
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2023 12:33 PM - edited ‎10-02-2023 12:34 PM
I'm syncing the parent and child incidents states in extended incident table.
When updating parent1 incident state from InProgress to new, Only Child 1 is changing the state and other child(Child 2) incident state are still in InProgress.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2023 01:10 PM - edited ‎10-02-2023 01:14 PM
HI @R Charan C
You update the function code with:
var child_inc = new GlideRecord('incident');
// var child_inc = new GlideRecord('extended_incident'); //extended incident table
child_inc.addQuery('parent_incident', current.sys_id);
child_inc.query();
gs.info("childIncidentsBusinessRule: Found " + child_inc.getRowCount() " child incidents for " + current.number);
while (child_inc.next()) {
child_inc.state = current.state;
child_inc.hold_reason = current.hold_reason;
gs.info("childIncidentsBusinessRule: Set child_inc: " + child_inc.number + " state: " + current.state " hold_reason: " + current.hold_reason);
if (current.state == 7 || current.state == { //close or canceled
gs.info("childIncidentsBusinessRule: Set child_inc: " + child_inc.number + " close_notes: " + current.close_notes " close_code: " + current.close_code);
if (child_inc.close_notes == "") {
child_inc.close_notes = current.close_notes;
}
if (child_inc.close_code == "") {
child_inc.close_code = current.close_code;
}
}
child_inc.update();
}
Test, then check Script Log Statements, with "message", "starts with", "childIncidentsBusinessRule" to see what is going on. And please note, the code you have doesn't have the last "}". for the function definition. And for some reason, when I past the modified code, this post is messing up the line:
if (current.state == 7 || current.state == 😎 { //close or canceled
I see a smiley face where "8" should be.