will closing bulk sctask with workflow false still trigger notification of RITM and REQ on autoclose

saint
Tera Expert

How to bulk close sc_task records without triggering closure emails on RITM (sc_req_item) and REQ (sc_request)

10 REPLIES 10

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).

 

 

 

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

I'm going with option A for now, but will keep digging to find why its not triggering. Thank you!

pavani_paluri
Kilo Sage

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 it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

Nishant8
Tera Sage

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

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.