How to use deleteMultiple
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2023 04:08 PM - edited 07-29-2023 04:09 PM
Hi Team,
kindly help me on how to use deleteMultiple, which is best practice.
var gr = new GlideRecord('incident');
gr.addQuery('activ=false');
gr.query();
if(gr.next())
{
gr.deleteMultiple();
}
OR
var gr = new GlideRecord('incident');
gr.addQuery('activ=false');
gr.query();
gr.deleteMultiple();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2023 05:17 PM - edited 07-29-2023 05:47 PM
Here’s an example script you can use for deleteMultiple. When doing a deleteMultiple, there is no need for the Query(). It’s also best to delete in chunks
var gr = new GlideRecord('table');
gr.addEncodedQuery(‘yourencodedqueryhere');
gr.setLimit(1000);
gr.deleteMultiple();
with that said, if your trying to do 100k records, use the table cleaner
Mark ✅Correct if this solves your issue and also mark 👍Helpful if you find my response helped in any way
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2023 05:34 PM
Hi ,
Daniel makes a good point, on deleting records in chunks. But you must use the proper field name 'active' not 'activ'. in your script.