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.

Help populating a list collector with values from another list collector

johannaS
Tera Expert

I want to run an advanced business rule where a list collector updates its child record with the same value on the child's respective list collector.  If I pull the value from the parent and then set the value to the child field, it updates but is blank rather than updated. What are the steps to do this in a  business rule script? 

1 ACCEPTED SOLUTION

SVimes
Kilo Sage

List collectors are "fun" to play with. When you get the data from the field, don't use getDisplayValue(), just use getValue() or just current.field to get the underlying sys_ids of the list of records in the field. Convert that retrieved value to a string as well. Once you have that, you should just be able to put that value into the field of the child record (setValue('field', listCollector)) and do child.update().

 

var childRec = new GlideRecord('child_table')
childRec.get(current.child_field);

var parentList = current.listCollector_field.toString(); //or current.getValue('listCollector_field').toString();
childRec.listCollector_field = parentList;
childRec.update()

 

Sable Vimes - CSA

View solution in original post

1 REPLY 1

SVimes
Kilo Sage

List collectors are "fun" to play with. When you get the data from the field, don't use getDisplayValue(), just use getValue() or just current.field to get the underlying sys_ids of the list of records in the field. Convert that retrieved value to a string as well. Once you have that, you should just be able to put that value into the field of the child record (setValue('field', listCollector)) and do child.update().

 

var childRec = new GlideRecord('child_table')
childRec.get(current.child_field);

var parentList = current.listCollector_field.toString(); //or current.getValue('listCollector_field').toString();
childRec.listCollector_field = parentList;
childRec.update()

 

Sable Vimes - CSA