To delete records safely in ServiceNow without a script, use a delete job in Core UI or a one-time delete rule in Data Management Console. Preview the cascade count first, since a delete can remove records that reference it. Rollback and delete recovery can restore records afterwards, but each window is short, and availability depends on your database type.
Choosing between a delete job and a one-time delete rule
A delete job works from a selection of records you mark for deletion, and it lives under System Data Management. A one-time delete rule is built in Data Management Console, can carry a later run date, and includes a step for choosing which associated records go with it. Pick the route that matches how you find the records.
| Route | Where it is built | Best fit | Way back |
|---|---|---|---|
| Delete job | All > System Data Management > Delete jobs | A defined set you can preview before running | Rollback related link on the completed job |
| One-time delete rule | Data Management Console, Overview or Rules tab | A condition-based set with a review step | Rollback context, created by default |
| Table cleaner | Data Management, older or unwanted records | Clearing a whole table | Outside the scope of this page |
Deleting all records in a table is a different job. The table is locked while the delete runs, so the table cleaner is the better fit. The archiving and table cleaner guide covers that route.
Preview the cascade before anything runs
Deleting a record can also delete the records that point at it. When a job executes, up to three levels of cascaded records are removed. Matched incidents bring along the problems that reference them, the defects that reference those problems, and the test records that reference those defects. Each level can add rows you did not plan to lose.
Attachments need a separate check. Attachment records tied to matched records can be deleted even when they do not appear in the preview.
In a delete job, select the Preview Cascade related link to see how many source records match. Counts for records in other tables are close estimates. Write the numbers down before you run the job, so you have something to compare against after a rollback.
For a one-time rule, Preview affected records on the conditions page opens the matching list in a new browser tab. Preview cascade on the Delete associated records page shows the estimate for each table.
Running a delete job now or on a schedule
Open the job from All > System Data Management > Delete jobs. You can schedule a date and time, or execute the job immediately. Consider scheduling it outside business hours to limit the potential performance impact on users. Deleting all records in a table locks it while the job runs, which blocks inserts and updates from users.
Schedule a date and time for the delete job, or choose to run it right away from the delete job record.
Building a one-time delete rule in Data Management Console
You need the admin role. Work through the wizard in this order.
- Open All > System Data Management > Data Management Console. From the Overview tab, select the table and choose Create rule. Or use the Tables tab, open the table’s Rules tab, and choose Create rule.
- On Define your rule, choose One-time delete and enter a name. The name is the display value wherever the rule is referenced, so choose one that reads clearly in those places.
- On Define conditions, build the filter from a field, an operator and a value. Combine conditions with OR and AND, or add a condition set. A smaller match set lowers the chance of locking the table. Then preview the affected records.
- On Delete associated records, preview the cascade and check each table’s estimate. A rollback context is created by default at this step. You can also choose to run business rules and engines after the deletion.
- On Set up schedule, pick Execute upon creation or Schedule later with a Run at time. A later run can match a different number of records, so repeat the preview if the date moves.
- On Rule summary, review the settings, select the acknowledgment statement, and activate the rule along with its data management policy. Both must be active before the rule runs.
Deleting records can cause unexpected cascade deletion in related tables, so set the conditions narrowly and check the counts before you activate. For records that must be removed on a recurring basis, use a cleanup rule instead of a one-time rule.
Rolling back a delete job
Open the executed delete job from All > System Data Management > Delete jobs, select the Rollback related link, and confirm. The rollback restores the deleted records straight away.
Restoring is not the same as cancelling. If the records should stay gone, create a new delete job with the same conditions, then schedule it or execute it immediately.
Recovering a single deleted record
Two modules recover individual records. Each has its own reach and time limit, so choose by what you need back.
Deleted Records module
Find it at All > System Definition > Deleted Records. The instance can track deletions on any table, with exceptions. Tables that carry the no_audit_delete dictionary attribute set to true do not track deletions, and sys-prefixed tables do not track them by default, although auditing can be enabled for a system table.
You restore one deleted record and its references at a time. Choose one of these options:
| Option | What it restores |
|---|---|
| Undelete With Related | The record, plus its cascaded deletes and other database actions from that delete. Shown when a rollback context exists |
| Recover entire operation | All records from the parent delete, including cascades. For a top-level delete this matches Undelete With Related. Shown when a rollback context exists |
| Undelete Record | That one record |
Plan around three limits. References come back only when the reference field sits on an audited table and the Restore Deleted Record plugin is active; reference fields of the Image type are not restored. Restoring is an insert, which can fire business rules and cause further inserts and updates on related records, so the outcome on related tables can be hard to predict. Test that path on a non-production instance before relying on it. Cascaded records can be recovered within seven days of the deletion. After seven days, recovery is limited to data records and references on tables that audit deletions.
Select Restore deleted record to start. A progress page reports the references restored, and a Restore Summary lists the changes with links to the restored record.
Delete Recovery module
Find it at All > Rollback & Recovery > Delete Recovery. It works for any deleted record, but recovery must happen within seven days of the deletion. Open the item, select Rollback… under Related Links, enter yes in the Rollback entire operation form, and select OK.
Database types and time windows
Rollback and delete recovery depend on the database engine behind the instance, so check it before you plan a restore.
| Database type | Rollback | Delete recovery |
|---|---|---|
| MySQL | Yes | Yes |
| MariaDB | Yes | Yes |
| Oracle | Yes | No |
| SQL Server | No | No |
A rollback context is created when a GlideRecord delete or deleteMultiple removes records. Patch upgrades, plugin activations and background script runs also create contexts, but this page covers the delete side. Two plugins support the feature: Restore Deleted Records (com.snc.undelete) and Delete Recovery (com.glide.delete_recovery). A rollback leaves alone any record that another database activity changed afterwards.
| Item | Default window | Property that changes it |
|---|---|---|
| Delete Recovery and cascaded recovery | Seven days from the deletion | None listed |
| Rollback context for a delete | 10 days after the delete completes | glide.rollback.expiration_days_delete |
| Stuck rollback contexts | 30 extra days beyond normal expiry | glide.rollback.stuck_expiration_days |
| Script Execution History | Seven days | None listed |
A scheduled job named Clean Expired Rollback Contexts runs daily to remove expired contexts. To keep a delete context longer than 10 days, add the glide.rollback.expiration_days_delete property in the System Properties table with an integer value. Longer retention keeps more data on the instance.
Frequently asked questions
Can I undo a delete job after it has run?
Yes, while its rollback is still available. Open the completed job, select the Rollback related link, and confirm. By default, a delete’s rollback context lasts 10 days after the delete completes.
Why does the preview count differ from what gets deleted?
Counts for other tables are estimates, and attachment records can be removed without appearing in the preview. A rule scheduled for later can also match a different set of records by the time it runs.
Should I use a delete job to empty a table?
No. Deleting all records in a table locks it while the job runs, which blocks inserts and updates. Use the table cleaner for that work.
Does restoring a record bring back the records that pointed to it?
It depends on the option. Undelete With Related restores the record with its cascaded deletes when a rollback context exists. Undelete Record restores that one record.
Which database types support delete recovery?
MySQL and MariaDB support both rollback and delete recovery. Oracle supports rollback but not delete recovery, and SQL Server supports neither.
For a wider view of keeping an instance responsive, see the platform performance guides.