- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
How to bulk close sc_task records without triggering closure emails on RITM (sc_req_item) and REQ (sc_request)
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @saint
Then go for workaround.
Identify which notification is getting trigger.
When you raise change to do this activity in prod in business off hour,
Update instruction as
1. deactivate notification A, Notification B etc.
2. Run fix script -> completed
3. Activate notification A, Notification B etc.
Or else
Raise a case (Hi ticket) to know why Notification triggering is not getting stop even after using setUseEngines(false) AND SerWorkflow(false).
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @saint
Then go for workaround.
Identify which notification is getting trigger.
When you raise change to do this activity in prod in business off hour,
Update instruction as
1. deactivate notification A, Notification B etc.
2. Run fix script -> completed
3. Activate notification A, Notification B etc.
Or else
Raise a case (Hi ticket) to know why Notification triggering is not getting stop even after using setUseEngines(false) AND SerWorkflow(false).
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I'm going with option A for now, but will keep digging to find why its not triggering. Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @saint ,
We can do it via background script using setWorkflow(false); but to the RITM and REQ you have to glide record and close them too with same setWorkflow(false).
var gr = new GlideRecord('sc_task');
gr.addQuery('numberIN', <sctask numbers>); // or any filter you need
gr.query();
while (gr.next()) {
//RITM
var grRitm = new GlideRecord('sc_req_item');
grRitm.get(gr.request_item);
grRitm.setWorkflow(false);
grRitm.state =3;
grRitm.update();
//REQ
var grReq = new GlideRecord('sc_request');
grReq.get(grRitm.parent);
grReq.setWorkflow(false);
grReq.state =3;
grReq.update();
gr.setValue('state', 3); // Closed Complete
gr.setWorkflow(false); // prevents business rules/workflows
gr.update();
}
we can cancel the workflows running on RITM via script as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @saint, Please include setUseEngines(false) as well along with setWorkflow(false).
Close them in chunks if there are plenty. Also, try for couple of tasks before doing mass update.
Regards,
Nishant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi I added setUseEngines(false) to my script and it didn't work as expected. The REQ autoclose email still got triggered. Thanks for the response.