Convert Business rule to Fix Script to update the old records in a table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2024 06:57 AM
Hello everyone,
I want to convert the below Business rule to Fixscript.
After Insert and Update BR
Written on Key_values Table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2024 07:08 AM - edited 08-16-2024 07:16 AM
You would first add a GlideRecord on the Key Value table, to return records with Value = dev, acc, or prod, and configuration_item.instance not Development, Acceptance, or Production - or whatever your criteria for updating these records is. In the while loop of this first GR will be your existing script replacing current.configuration_item and value with the keyvalueGR.configuration_item and value. So something like this:
var keyvalues = new GlideRecord('cmdb_key_value');
keyvalues.addQuery('value', 'IN', 'dev, acc, prod');
keyvalues.addQuery('configuration_item.instance', 'NOTIN', 'Development, Acceptance, Production' );
keyvalues.query();
while (keyvalues.next()){
var data = new GlideRecord('cmdb_ci_cloud');
data.addQuery('sys_id', keyvalues.configuration_item);
data.query();
if (data.next()) {
if (current.value == 'dev')
data.instance = 'Development';
else if (current.value == 'acc')
data.instance = 'Acceptance';
else if (current.value == 'prod')
data.instance = 'Production';
data.update();
}
}