Background Script to update Multiple Records
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-18-2022 10:18 AM
Hi team, I want a background script to update the field (category) from the KB knowledge table based on the field (business criticality) from the Business application table.
For example - If the Business criticality field value is platinum then the category field should be updated to platinum by using the background script. I am new to coding, Please advise
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2022 10:35 AM
Hi there,
You can use the below background script and add further else if () statements as needed:
var knowGr = new GlideRecord('kb_knowledge');
knowGr.query();
while (knowGr.next()) {
if (knowGr.cmdb_ci.business_criticality.toString() == 'platinum') {
knowGr.setValue('category', 'sys_id_of_platinum_kb_category_record_here');
knowGr.update();
} else if (knowGr.cmdb_ci.business_criticality.toString() == 'gold') {
knowGr.setValue('category', 'sys_id_of_gold_kb_category_record_here');
knowGr.update();
}
}
If this answer is helpful please mark correct and helpful!
Regards,
Christopher Perry
If this answer is helpful please mark correct and helpful!
Regards,
Chris Perry
Regards,
Chris Perry