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

scheduled job to delete records based on condition

CV1
Tera Contributor

Hello All,

We have huge number of records in sys_user table that needs to be deleted based on filter. I want to run a scheduled job  to delete  say 1500 records a day till the condition is satisfied at 1am. Please see the screenshot and advise if this is good or any modifications needed.

TIA

1 REPLY 1

SN_Learn
Kilo Patron
Kilo Patron

Hi @CV1 ,

 

The script looks okay.

I would suggest to update the addQuery with addEncodedQuery and try to log without  once to check if the correct details are coming up.

 

 

var grInc = new GlideRecord('incident');
grInc.addEncodedQuery('your_encoded_query'); //from list view your can pull out this
grInc.setLimit(1500);
grInc.query();
gs.log("Deleting user Records:  " + grInc.getRowCount());
//grInc.deleteMultiple();

 

Once verified that the total count is matching. Then you can uncomment the deleteMultiple() command and execute it in scheduled job.

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.