Business Rule and Scripting

KetanSelokar
Tera Contributor

Hello I'm new to scripting and don't know much how the BR works so have some doubts.

 

The thing is have created a "Before" Business rule with the conditions "Insert" or "updated" in the cmdb_rel_ci_list table to concatenate the Parent and child and update the Parent with the concatenation for some particular applications. The script is working fine and the applications are getting concatenated when I manually try to update the the record in the relationship table. But when the new relationship record is getting discovered or created in the cmdb_rel_ci_list the record is not getting updated as per the concatenation . Can you suggest how can I solve this issue this will be really helpful.

5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@KetanSelokar Please check if setWorkflow(false) was used anywhere in the script when the new relationship record is getting discovered or created in the cmdb_rel_ci_list the record.

 

Usage of setWorkflow(false) disables the subsequent invoking of other business rules which may come execute later depending upon the order. 

Hi @Sandeep Rajput I checked I haven't added setWorkflow(false) this is the reference script which I have created.
(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);

@KetanSelokar It is not you but the other script which is adding cmdb_rel_ci_list table.

Amit Pandey
Kilo Sage

Hi @KetanSelokar 

 

I believe the Business Rule might not be firing when the record is created automatically by discovery process. Ensure that the conditions for triggering the Business Rule and order of execution are correctly set. 

 

Regards,

Amit