Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

I want to delete five active incident records.

tapu
Giga Contributor

I want to delete five active incident records on incident table.

4 REPLIES 4

Tony Chatfield1
Kilo Patron

Hi, deletion of records is not recommended, but it is a simple UI action from the list view of the table.

Vaibhav Dane
Tera Expert

Hi,

 

You can use below code from background script to delete the records.

 

var incGR = new GlideRecord('incident');
incGR.addQuery('sys_id','IN',<sys_ids of the records>);
incGR.query();
if(incGR.next()){
incGR.deleteMultiple();
}

 

But it is not recommended to delete any records, you can deactivate the records.

Regards,

Vaibhav Dane

Hii Vaibhav,

I want to delete only five active incident records.

Kalyani Jangam1
Mega Sage

Hi, If this any 5 Random active record then you can use below code also

var gr=new GlideRecord("incident");
gr.addEncodedQuery("active=true");
gr.setLimit(5);
gr.query();
gs.info(gr.getRowCount());
gr.deleteMultiple();