- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 07:01 AM
Hi,
I want to delete around 20k record, could you please help me the best way to do so. I don't want to make my system slow during deletion.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 11:23 PM
Hi @MK-p ,
My recommendation would be instead of deleting those record you can archive it. Benefit of archive is you can refer any point of time in future and if these records are not relevant to your client then you can use below code to delete.
Create a fix script and use below code.
var grObj = new GlideRecord('your_table_name');
grObj .addEncodedQuery('your_encoded_query'); // Specify the condition for the records to delete
grObj .deleteMultiple();
//For Example
//if i want to delete all incident having no short description then my code would be like this.
var incGr = new GlideRecord('incident');
incGr.addNullQuery('short_description');
incGr.deleteMultiple();
Please Mark Correct if this solves your query and also mark Helpful if you find my response worthy based on the impact.
Regards,
Runjay Patel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 10:47 AM
Hi @MK-p ,
The best way, ServiceNow introduced Delete Jobs (module name). Using it you can select the table and filter the table.
Clicking Execute now, will delete the records.
The best thing is, it is best way when compared to scripts. The system does not slow down.
If the above information helps you, Kindly mark it as Helpful.
Regards,
Najmuddin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 11:23 PM
Hi @MK-p ,
My recommendation would be instead of deleting those record you can archive it. Benefit of archive is you can refer any point of time in future and if these records are not relevant to your client then you can use below code to delete.
Create a fix script and use below code.
var grObj = new GlideRecord('your_table_name');
grObj .addEncodedQuery('your_encoded_query'); // Specify the condition for the records to delete
grObj .deleteMultiple();
//For Example
//if i want to delete all incident having no short description then my code would be like this.
var incGr = new GlideRecord('incident');
incGr.addNullQuery('short_description');
incGr.deleteMultiple();
Please Mark Correct if this solves your query and also mark Helpful if you find my response worthy based on the impact.
Regards,
Runjay Patel