update the list type field on a parent incident with multiple child incidents with unique values

Richard Tyler
Tera Expert

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.

 

(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()) {
        parentincident.u_user_location=current.u_user_location;
       
        parentincident.update();
    }

})(current, previous);
1 REPLY 1

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Richard Tyler ,

 

Try updating this line

 

parentincident.u_user_location += current.u_user_location;

 

Thanks,

Danish