Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to delete multiple sc_task with task numbers

nishtha6
Tera Contributor

Hi,

 

Could you please help me with background Script for below condition:
How to delete multiple sc_task with the help of task numbers e.g SCTASK0364621, SCTASK0364622, SCTASK0364623, SCTASK0364624, SCTASK0364625, SCTASK0364626, SCTASK0364627, SCTASK0364628 and so on...........

1 ACCEPTED SOLUTION

@nishtha6 , whatever record you need to delete you can add under this query after IN,

 

numberINSCTASK0364621, SCTASK0364622, SCTASK0364623, SCTASK0364624, SCTASK0364625, SCTASK0364626, SCTASK0364627, SCTASK0364628

View solution in original post

4 REPLIES 4

Jayant_M
Kilo Sage

Hi @nishtha6 

Try below background script:

 

var gr = new GlideRecord('sc_task');

gr.addEncodedQuery('numberINSCTASK0364621, SCTASK0364622, SCTASK0364623, SCTASK0364624, SCTASK0364625, SCTASK0364626, SCTASK0364627, SCTASK0364628');

gr.query();

while (gr.next()){
 gr.deleteMultiple();

 

}

 

Please mark my answer helpful if it resolves your issue

nishtha6
Tera Contributor

Hi Jayant,

 

Thank you, i tried this but its deleting all sc task records 

@nishtha6 , whatever record you need to delete you can add under this query after IN,

 

numberINSCTASK0364621, SCTASK0364622, SCTASK0364623, SCTASK0364624, SCTASK0364625, SCTASK0364626, SCTASK0364627, SCTASK0364628

nishtha6
Tera Contributor

thank you, its working