Creation of BR for concatenating the Parent and child in cmdb_rel_ci_list.

KetanSelokar
Tera Contributor

I wrote the following BR rule to concatenate the values of the parent and child reference fields, store them in a variable, and then glide and update the "Name" field on the Parent record with the concatenation if the condition meets. I'm not sure what should be the "When to Run" condition if records are inserted in the relationship table (cmdb_rel_ci_list) through discovery or if the records are updated.

(function executeRule(current, previous /*null when async*/ ) {
var sys = current.getValue('parent');  
var concat = current.getDisplayValue('parent') + '@' + current.getDisplayValue('child');  
var app = GlideRecord('cmdb_ci_appl_XYZ'); 
app.addEncodedQuery('xyz');                         
app.query();

while (app.next()) {                                             
if (app.sys_id == sys) {
app.name = concat;
app.update();
}
}
})(current, previous);

1 REPLY 1

HrishabhKumar
Kilo Sage

Hi @KetanSelokar ,

If you need to execute this logic on records being updated or created by discovery you can use that condition in when to run. i.e.

Record is created, or 

Record is updated

and

Discovery source is Discovery.