
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 03:44 AM
We have a requirement in the company to sync certain fields down from a Parent Incident to each of its Child Incidents. This are the Business Service, Assignment Group and Assigned To.
Little wrinkle to that is you can only select an Assigned To that is in the Assignment Group chosen.
So I've had a Business Rule in for a while that runs After Update of the Parent Incident, and it will check the Child to make sure things match.
However, it's become clear recently that this isn't working correctly, and in fact every single time a worknote or comment are added to the Parent, or another INC is linked to the Parent, then every single Child Incident is getting their Assigned To wiped and re-added - even on Closed tickets, which is then triggering closed emails and surveys again.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 03:52 AM - edited 07-24-2024 03:53 AM
HI,
You cannot use childIncidents.assignment_group before .next() as it will not have any value to compare
Try this
(function executeRule(current, previous /*null when async*/) {
var childIncidents = new GlideRecord('incident');
childIncidents.addQuery('parent_incident', current.sys_id);
childIncidents.query();
while (childIncidents.next()) {
if (childIncidents.assignment_group != current.assignment_group) { //you cannot use this before .next()
childIncidents.assigned_to = '';
childIncidents.assignment_group = current.assignment_group;
childIncidents.update();
childIncidents.assigned_to = current.assigned_to;
childIncidents.update();
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 03:51 AM
Hello @StewartF ,
Can you try below script -
(function executeRule(current, previous /*null when async*/) {
// Query for child incidents
var childIncidents = new GlideRecord('incident');
childIncidents.addQuery('parent_incident', current.sys_id);
childIncidents.query();
while (childIncidents.next()) {
// Check if the child incident's assignment group is different from the current incident's assignment group
if (childIncidents.assignment_group != current.assignment_group) {
// Clear the assigned_to field
childIncidents.assigned_to = '';
// Update the assignment group
childIncidents.assignment_group = current.assignment_group;
childIncidents.update();
}
// Update the assigned_to field to match the current incident's assigned_to
if (childIncidents.assigned_to != current.assigned_to) {
childIncidents.assigned_to = current.assigned_to;
childIncidents.update();
}
}
})(current, previous);
If my answer solves your issue, please mark it as Accepted and Helpful!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 03:52 AM - edited 07-24-2024 03:53 AM
HI,
You cannot use childIncidents.assignment_group before .next() as it will not have any value to compare
Try this
(function executeRule(current, previous /*null when async*/) {
var childIncidents = new GlideRecord('incident');
childIncidents.addQuery('parent_incident', current.sys_id);
childIncidents.query();
while (childIncidents.next()) {
if (childIncidents.assignment_group != current.assignment_group) { //you cannot use this before .next()
childIncidents.assigned_to = '';
childIncidents.assignment_group = current.assignment_group;
childIncidents.update();
childIncidents.assigned_to = current.assigned_to;
childIncidents.update();
}
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 03:56 AM
See what I meant when I said it's questionable if I'm even a good scripter? Haha thank you @Anurag Tripathi that works exactly how it's supposed to now!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 03:57 AM
Cheers mate.