Close hung Requests without sending out email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2018 08:47 AM
Hello everyone,
Unfortunately a few of our key workflows were not done correctly. The tasks were closed and the RITM's were closed but the REQ's remain open. We now have 2100 REQ's that need to be closed and I would like to pick your brains for a method to do so without sending out the 2100 emails that ServiceNow will want to send. In the mind of the requester everything is complete so they are not waiting for any further word. Would this be possible with a scheduled job or do we need to do something drastic such as turn off email during off hours, close the REQ's and then clear the email that it creates before turning it back on?
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2018 08:53 AM
I would suggest to deactivate the notification for sometime, if you do this then you don't need to delete the email logs.
Also to close the 2100 requests, you need to create the Scheduled job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2018 08:56 AM
What I've done in the past is I've added a condition to the notification so it sends unless 'closed by = myself'. That way the notifications keep flowing normally, except for the junk I'm cleaning up.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2018 09:03 AM
You should create a Fix Script that will loop through your records and mark them inactive and set the state appropriately. Before your update you can use the setWorkflow(false) to prevent business rules, notifications, etc to not process by that update:
https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=r_GlideRecord-setWorkFlow_Boolean
The following blog article may be useful and also includes setWorkflow(false):
https://community.servicenow.com/community?id=community_blog&sys_id=60ccee25dbd0dbc01dcaf3231f961946
Please mark the post helpful or the correct answer to your question if applicable so others viewing can benefit.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-19-2018 12:04 AM
Hi Michael,
I tried to get this script working in my sandbox and unfortunately it just closed everything as opposed to just the REQ's that had closed RITM's. Can you assist me in figuring out where I went wrong with this scheduled job?
closeREQ();
function closeREQ(){
var req = new GlideRecord('sc_request');
req.addQuery('active', 'true');
req.query();
while (req.next()) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('active', 'false');
ritm.addQuery('request',req.sys_id);
ritm.query();
if (ritm.hasNext()) {
//closeItem = false;
}
else {
req.state = '3';
req.active = 'false';
//req.comments = 'Closing REQ on account of all underlying RITMs marked Closed';
req.update();
}
}
}