- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 12:41 PM
Can anyone provide a script to remove records created on a specific date?
Something went wrong today and we ended up with Duplicates of all records on our vendor table.
I need a script that will delete all records created on 7/28/2016 in Core_Company table.
Please let me know and thanks!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 01:26 PM
Hi Carl,
Slight modification to the script shared by Abhniay. Enclosed code in function and added setWorkflow line to turn of notification/BR
Script :
delCoreCompanyRec();
function delCoreCompanyRec()
{
var gr= new GlideRecord("core_company");
gr.addEncodedQuery("sys_created_onON2016-07-28@javascript:gs.dateGenerate('2016-07-28','start')@javascript:gs.dateGenerate('2016-07-28','end')");
gr.setWorkflow(false); //Don't fire Business rule,notifications
gr.deleteMultiple();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 12:47 PM
Here you go
var gr= new GlideRecord("core_company");
gr.addEncodedQuery("sys_created_onON2016-07-28@javascript:gs.dateGenerate('2016-07-28','start')@javascript:gs.dateGenerate('2016-07-28','end')");
gr.deleteMultiple();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 12:48 PM
Before deleting them, use this in the background script and see if you get correct number
var gr= new GlideRecord("core_company");
gr.addEncodedQuery("sys_created_onON2016-07-28@javascript:gs.dateGenerate('2016-07-28','start')@javascript:gs.dateGenerate('2016-07-28','end')");
gs.print(gr.getRowCount());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 12:53 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2016 12:54 PM
Oops, missing gr.query(); in the script. Try this
var gr= new GlideRecord("core_company");
gr.addEncodedQuery("sys_created_onON2016-07-28@javascript:gs.dateGenerate('2016-07-28','start')@javascript:gs.dateGenerate('2016-07-28','end')");
gr.query();
gs.print(gr.getRowCount());