You are currently viewing Best Ways To Delete Mass Data In ServiceNow

Best Ways To Delete Mass Data In ServiceNow


Welcome to ServiceNow Spectaculars.

This article focuses on mass deletion in ServiceNow. Data is growing day by day; hence, it is required to maintain data within ServiceNow tables. Apart from deletion, you may have other options as well, such as data archiving, data filters, and many more. But in many cases, we need to delete data from bulky ServiceNow tables. So, in these cases, we are bound to do mass deletions of data from tables.

Why do we mass delete data from tables?

There are many reasons to do mass delete:

  • Huge Data: In cases where the table has unprecedented data and most of it is old and not needed,
  • Corrupted Data: In cases where the data is corrupted due to a human or technical glitch and is not needed anymore,
  • Performance Issue: When getting performance issues while accessing the table data
  • Useless Data: In cases where the data is useless because of any upgrade, update or change in processes

Apart from this, you may have any other situation that demands the deletion of data from tables, whether partial or complete.

Can we ask ServiceNow to Delete data?

  • Mostly, ServiceNow does not intervene in data deletion process unless the data is causing any P1 impact in terms of performance or accessibility
  • However, due diligence and approval are needed from the customer’s side under any circumstances.
  • It is basically the customer’s task to delete data in any of the ways or others provided below.

Precautions Before Bulk Deletion

You must have a plan to accomplish this and be ready to tackle any type of issues arises during runtime.

  • How to tackle cascade deletion?
  • How to manage orphan record post deletion?
  • How to manage notification if triggered on deletion?
  • Analysis the impact on reporting?
  • Analyze the impact on all users using that data?
  • When you perform deletion?
  • Take care of any workflow/ business rule triggered.
  • Impact on other applications i.e. collateral damage control

What Are The Alternatives Of Delete?

  • You can archive the data
  • You can Retire the records
  • Write before query business rules to show only limited data

Possible Ways to Do Mass Delete?

Depending upon situation you can opt any of the following way to delete data:-

  • Simple delete from UI actions
  • Using Clone Exclude Rules
  • Using Table Cleanup Policies
  • Using JavaScript

UI Actions

  • It is one of the simplest way to do bulk delete
  • However, it is comparatively slow and tend to cancel by UI Transaction Quota Rule
  • The default limit to UI Transaction Quota Rule is 5 mins, so you have to update it accordingly
  • So, check if this deletion triggers workflow & business rules and manage the quota timing accordingly
  • You can delete all records at once i.e. Go to your table record in “sys_db_object” table and click on UI action “Delete All Records”
  • This query is basically do the function of deleteMultiple() function of GlideRecord.
var grDel = new GlideRecord("table_name");

Deletion Via Clone Exclude Rules

  • This is one of the fast way to delete data from tables
  • However, it need better planning and assessment because it is done during the cloning.
  • It has no conditional option but entire table will be truncated.
  • As this is done during cloning, not viable for production but only sub productions instances.
  • It has higher tendency to leave broken or orphan records.
  • So, wherever it is used as reference , SysId will be available with no references record.

Deletion Using Table cleanup Policies

  • This is done using the table cleaner job
  • It is one of the safe and secure way to do conditional deletions from tables
  • The Table Cleaner Job run one time every hour
  • So we just need to schedule it and then it will be picked up by job and executed i background
  • You can consider this option for any kind of routine deletions such as deleting closed tasks etc
  • It provide an option of Silent Delete i.e. without any cascade effect as well
  • That means no business rules or workflows will be triggered by the deletion, which can significantly improve performance

Using JavaScript To Delete

  • Writing a script provides most flexibility
  • But writing script need spcial compand over programing
  • Because a bad script can do much worse than you think
  • It has no time limit but you have to be cautioned
  • Opportunity to bypass business rules, workflows, and other engines
  • Use setWorkflow(false) to bypass above engines
  • Available for full delete or condition delete of records
var grDel = new GlideRecord("table_name");
grDel.setWorkflow(false); // Bypass business rules and workflows
end footer

Leave a Reply