- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 06:54 AM
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
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2019 07:13 AM
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.
var incs = gs.getProperty('inc.numbers'); //Your property name here
var gr = new GlideRecord('incident');
gr.addEncodedQuery('numberIN'+incs);
gr.deleteMultiple();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2019 08:32 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-22-2022 03:13 AM
i have a question here what if i have to delete the records ignoring the result of the encoded query(i.e the records returned from the encoded query must be there rest all should be deleted )
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2019 06:49 AM
Last question (I hope!):
In the script provided, where would I enter the incident numbers?
var incs = gs.getProperty('inc.numbers'); //Your property name here
var gr = new GlideRecord('incident');
gr.addEncodedQuery('numberIN'+incs);
gr.deleteMultiple();
Again, I'm sorry if this is obvious - I've been thrust into a Admin/Dev role but am still playing catch-up.
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2019 06:55 AM
Number will go in system property
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2019 07:00 AM
I have added a image in my last reply. You need to navigate to System properties table ie
sys_properties.LIST and add a new entry in here exactly as I have added in the image.
You could also reuse this in future if required.