The CreatorCon Call for Content is officially open! Get started here.

Need a script to delete the bulk data from tables in servicenow ? EX : RITMS, USERS,TEST TICKETS etc..

katz2
Tera Contributor

Need a script to delete the bulk data from tables in servicenow ? EX : RITMS, USERS,TEST TICKETS etc..

1 ACCEPTED SOLUTION

syedfarhan
Kilo Sage

Hi Karthick,



I hope this post may help you Remove Demo Data from your Instance without submitting an Incident




and you can try this too



Name: Remove All Data from a Table


Type: Background Script.


Table: Specified in the function parameter.


To run this script:


Navigate to System Definition > Scripts - Background.



Change table_name in the script to the name of the table you want to delete all records from.




Script:


doit("table_name");


//for example doit("cmdb_ci");



function doit(table) {


  var gr = new GlideRecord(table);


  gr.query();


  gr.deleteMultiple();


}



Thanks


View solution in original post

7 REPLIES 7

you can also use solution as suggested by Syed, but unfortunately it does not delete attachments.


This is a manual activity and it takes lot of time.. thats why we are looking for some script to do it.


Adarsh Krishnam
ServiceNow Employee
ServiceNow Employee

You can follow the below KB for mass deletion.

 

https://hi.service-now.com/kb_view.do?sysparm_article=KB0717791