Issue with updating RITM records is triggering a large number of emails
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 01:41 AM
Above script is directly updating the approval and RITM states in ServiceNow, which is triggering notification rules and business logic — especially since you're changing the approval state and setting RITMs to closed/incomplete. That explains the mail blast i an experiencing. Could you please me?
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 01:54 AM
updated as this
-> added setWorkflow(false) for approval records as well
var ritmGR = new GlideRecord('sysapproval_approver');
ritmGR.addEncodedQuery('state=requested^sysapproval.state=4');
ritmGR.query();
while (ritmGR.next()) {
// Update approval with workflows disabled
ritmGR.setWorkflow(false); // Disables notifications/business rules
ritmGR.autoSysFields(false);
ritmGR.state = 'rejected';
ritmGR.update(); // No notifications triggered here
// Update RITM
var reqItemGR = new GlideRecord('sc_req_item');
reqItemGR.addQuery('sys_id', ritmGR.sysapproval);
reqItemGR.query();
while (reqItemGR.next()) {
reqItemGR.setWorkflow(false); // Critical: Disables engines
reqItemGR.autoSysFields(false);
reqItemGR.state = 4; // Closed Incomplete
reqItemGR.stage = 'Closed Incomplete';
reqItemGR.approval = 'rejected';
reqItemGR.active = false;
reqItemGR.work_notes = 'Update by Fix Script';
reqItemGR.update(); // No notifications triggered here
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2025 08:34 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 02:04 AM
Use setWorkflow(false) while updating the Approval records same as RITM records which helps you prevent the system running other BR's and Notification engines.
Below line requires the change
// Set approver state to rejected
Thanks & Regards,
Vasanth