Business Rule and Scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 08:41 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 08:49 AM
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 09:07 AM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 09:15 AM
@KetanSelokar It is not you but the other script which is adding cmdb_rel_ci_list table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-06-2024 09:47 AM
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