update the list type field on a parent incident with multiple child incidents with unique values in
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 07:51 AM
I need to update a parent incident list type field with values from multiple child incidents. Each child incident is meant to pass a unique value to the parent incident to aggregate the vlaue in the parent incident.
My script updates the parent incident field, but when a new chield incident is related, the value of the field changes to the value of the newly related child incident. (replaces the value, not add)
How do i fix this? I am using a business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 09:17 AM
Hello @Richard Tyler ,
Below code will fix your issue:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var parentincident = new GlideRecord("incident");
parentincident.addQuery('sys_id', current.parent_incident);
parentincident.query();
if (parentincident.next()) {
if((parentincident.u_user_location) == ''){
parentincident.u_user_location =current.u_user_location;
}else{
parentincident.u_user_location += ','+current.u_user_location;
}
parentincident.update();
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2024 11:13 PM
Change the line after if
parentincident.u_user_location+= ','+current.u_user_location;