Background Script to Delete Multiple Incident Records

Scott Shewan
Kilo Contributor

Hi All,

 

Long time reader, first time poster.

 

Due to legal requirements, one of our clients has requested that 5,000+ incident records are deleted. We have been provided with a .csv file that contains all of these incident numbers.

 

We need to create a background script that will delete these records, or failing that, update the resolution notes (or anywhere, really) with something unique so that we can report against this "something unique" and cmd-click through all of them and delete them that way.

 

Truth be told, I'm agnostic as to how we get this done short of deleting them one by one by one by one.

 

Any help would be appreciated. 

 

Thanks,
Scott

1 ACCEPTED SOLUTION

You don't have to add incident numbers in the script, You just need to include those in the Value field of your System property. In the image it was shown in Choices field which is Incorrect and you can clear them off. And then add its name in the script.

find_real_file.png

var incs = gs.getProperty('inc.numbers'); //Your property name here
var gr = new GlideRecord('incident');
gr.addEncodedQuery('numberIN'+incs);
gr.deleteMultiple();

View solution in original post

12 REPLIES 12

Scott Shewan
Kilo Contributor

I don't think I'm asking the question clearly enough. After creating the new system property (as shown in Alikutty's VERY helpful screenshot), where would i plug those numbers into the script?

Like this?

var incs = gs.getProperty('INCXXX,INC123,INC577,etc'); //Your property name here
var gr = new GlideRecord('incident');
gr.addEncodedQuery('numberIN'+incs);
gr.deleteMultiple();

 

Hopefully my question makes more sense now. 

Also, thanks everyone for being so gracious with my ignorance!

 

You don't have to add incident numbers in the script, You just need to include those in the Value field of your System property. In the image it was shown in Choices field which is Incorrect and you can clear them off. And then add its name in the script.

find_real_file.png

var incs = gs.getProperty('inc.numbers'); //Your property name here
var gr = new GlideRecord('incident');
gr.addEncodedQuery('numberIN'+incs);
gr.deleteMultiple();

Alikutty, you beautiful genius! This did the trick!

 

THANK YOU!