- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2022 11:31 AM
We have about 915,600 emails stuck in send-ready in our UAT environment. I made a little fix script to set these from Ready to Ignored before enabling the email outbound. When I ran the script, it took me several hours before it clears out and don't want to spend the same amount of time when it happens again.
What's the better approach?
We should be able to clean this out in under a few minutes with a different approach right?
var gr = new GlideRecord('sys_email');
gr.addEncodedQuery('type=send-ready');
gr.query();
while (gr.next()) {
gr.state = 'ignored';
gr.type = 'send-ignored';
gr.update();
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2022 11:43 AM
Instead of a loop, right after gr.query, you can use gr.setValue and gr.updateMultiple() like so:
var gr = new GlideRecord('sys_email');
gr.addEncodedQuery('type=send-ready');
gr.query();
gr.setValue('state','ignored');
gr.setValue('type','send-ignored');
gr.updateMultiple();
You may be able to use updateMultiple() after setting gr.x, but I've only seen it used after setValue().
Frank

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2022 11:43 AM
Instead of a loop, right after gr.query, you can use gr.setValue and gr.updateMultiple() like so:
var gr = new GlideRecord('sys_email');
gr.addEncodedQuery('type=send-ready');
gr.query();
gr.setValue('state','ignored');
gr.setValue('type','send-ignored');
gr.updateMultiple();
You may be able to use updateMultiple() after setting gr.x, but I've only seen it used after setValue().
Frank
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2022 11:59 AM
I stopped at 600,000th email and tried using .updateMultiple() but no major change on the speed of setting the emails to ignored.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2022 12:01 PM
Hello
Did yu get a chance to check my comments?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2022 11:50 AM
Hello,
Please check the below article for recommend method of mass update of record
https://community.servicenow.com/community?id=community_blog&sys_id=60ccee25dbd0dbc01dcaf3231f961946
Please mark answer correct/helpful based on impact