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

Delete all records in a table script

carlh
Kilo Guru

abhi_r

Could you share a script to delete all records on the contract table and all records on the core_company VENDORs table?   There are about 1200 contracts and 4210 vendors. We want to start over and load fresh data for testing

I saw the one on the wiki but was scared to try without asking the community

Thanks

Carl

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Carl,



Here you go.


For first task :


delCoreCompanyRec();  


function delCoreCompanyRec()  


{  


var gr= new GlideRecord("core_company");  


gr.addQuery('vendor', true);  


gr.setWorkflow(false); //Don't fire Business rule,notifications  


gr.deleteMultiple();  


}



For second task :


delContractRecords();  


function delContractRecords()  


{  


var gr= new GlideRecord("ast_contract");  


gr.query();


gr.setWorkflow(false); //Don't fire Business rule,notifications  


gr.deleteMultiple();  


}



Run the above script from Background-scripts.


View solution in original post

12 REPLIES 12

Abhinay Erra
Giga Sage

You want to delete all the records in ast_contract and core_company table?


Yes



Just vendors = true on core company but all contracts



Get Outlook for iOS<https://aka.ms/o0ukef>


I am about to post the script, but looks like you have enough responses. I missed points on this one


@carl,



On your next thread please tag me as well