Bulk close records with comments or worknotes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi All,
I don't want to send email notifications and bulk close change records. Why is my fix script not updating the comments and worknotes ?
My code: -
var chg = new GlideRecord('change_request');
chg.addEncodedQuery('<YOUR_ENCODED_QUERY>');
chg.query();
gs.info("Changes found: " + chg.getRowCount());
while (chg.next()) {
chg.setWorkflow(false);
chg.autoSysFields(false);
chg.state = 3;
chg.comments = "This change is bulk closed";
chg.work_notes = "This change is bulk closed";
chg.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
update as this
See if any data policy is blocking the closure
var chg = new GlideRecord('change_request');
chg.addEncodedQuery('<YOUR_ENCODED_QUERY>');
chg.query();
gs.info("Changes found: " + chg.getRowCount());
while (chg.next()) {
chg.state = 3;
chg.comments = "This change is bulk closed";
chg.work_notes = "This change is bulk closed";
chg.setUseEngines(false); // disable data policy if any
chg.setWorkflow(false);
chg.autoSysFields(false);
chg.update();
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Ankur Bawiskar - used this code but, this is still sending the emails.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Did my script work to update the comments or worknotes?
how are the emails being sent?
via notifications, flow etc
when you use setWorkflow(false) it does disable the notification engine etc on that record
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
Try this ,
var chg = new GlideRecord('change_request');
chg.addEncodedQuery('<YOUR ENCODED_QUERY>');
chg.query();
gs.info("Changes found: " + chg.getRowCount());
while (chg.next()) {
chg.comments = "This change is bulk closed";
chg.work_notes = "This change is bulk closed";
chg.update();
var backendupdateChg = new GlideRecord('change_request');
if (backendupdateChg.get(chg.sys_id)) {
backendupdateChg.setWorkflow(false);
backendupdateChg.autoSysFields(false);
backendupdateChg.state = 3; // Closed
backendupdateChg.update();
}
}
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti