Restoring and Emptying Records
This page covers the operational workflows on the Recycle Bin page: restoring a single record, restoring everything at once, permanently deleting a single record (Del), and emptying the bin (Empty). Every action described here is performed from the Recycle Bin page at Setup > Manage > Recycle Bin.
Requirements
- Administrator System Role.
- Restore and Restore All require Edit permission on Recycle Bin.
- Del and Empty require Delete permission on Recycle Bin.
The Recycle Bin Page
The page is the standard administrator list view of every soft-deleted record currently in the bin. Columns: Action, Entity, Record Name, Modified By, Modified On. Sorted by Modified On descending so the most recently deleted items appear first.
Two toolbar buttons appear at the top:
- Restore All — restores every item in the bin (with confirmation).
- Empty — permanently deletes every item in the bin (with confirmation; runs in the background).
Each row has two per-row actions in the Action column:
- Restore — restores just that one record.
- Del — permanently deletes just that one record (with confirmation).
Restoring a Single Record
- Open Setup > Manage > Recycle Bin.
- Find the record in the list. Use the page's sorting and pagination to navigate.
- Click Restore on the matching row.
- The record is restored to its source entity and removed from the bin. The page returns you to the Recycle Bin list.
If the platform cannot restore the record (for example, the underlying entity does not support soft-delete), the failure is recorded in the system event log. The Recycle Bin row remains so an administrator can investigate or remove it manually.
Restore All
Restore All brings every item in the bin back to its source entity. The operation is intended for bulk-undo of large deletions, such as recovering from an accidental sweeping delete.
- From the Recycle Bin page, click Restore All in the toolbar.
- Confirm in the dialog.
- The platform restores items in dependency order: top-level items (those with no parent reference) first, then items whose parent reference is no longer in the bin in subsequent passes.
- The page redirects back to the Recycle Bin list when the operation completes.
The platform's ordering logic prevents infinite loops on circular references: if a pass restores nothing new, the operation stops. Items whose parent could not be resolved (for example, because the parent was permanently deleted, not just soft-deleted) remain in the bin and must be addressed individually.
Permanently Deleting a Single Record (Del)
Use Del when you want to remove a single record from the bin permanently — for example, to free its unique name for reuse, or to clear a specific item without affecting others.
- Find the record in the Recycle Bin list.
- Click Del on the row.
- Confirm in the dialog.
The Del action performs a forced permanent delete: it uses host mode and system mode, and skips standard validation. This is intentional — the bin entry has already been soft-deleted by the user, so the permanent removal is intended to bypass validations that would otherwise block the cleanup. If the permanent delete still fails (typically because of a foreign-key constraint at the database level), the error is logged and the item remains.
Emptying the Bin (Background Operation)
Empty permanently deletes every item currently in the bin. Because the bin can hold a lot of records (and each deletion runs through business logic), the operation runs in a background thread rather than blocking the page.
- From the Recycle Bin page, click Empty in the toolbar.
- Confirm in the dialog.
- The platform starts a background thread and returns immediately with the message: Recycle Bin is being emptied, Please check later for progress.
- You can leave the page. To check on progress, return to Setup > Manage > Recycle Bin. While the operation runs, the page displays an in-progress message: Recycle Bin is being emptied, Please check later or refresh the page to see the progress...
- When the in-progress message no longer appears, the empty run has completed.
The empty operation makes up to three passes over the remaining items. Each pass attempts to delete top-level items first, then children whose parent is no longer in the bin. Per-item exceptions during empty (for example, a database-level foreign-key error) are logged via the system event log and do not stop the rest of the batch.
If a previous Empty is still running when you click Empty again, the page simply re-displays the in-progress message — the platform does not start a second concurrent empty operation.
Restore-All Pseudocode
To make the dependency-ordering behavior concrete, the platform iterates roughly as follows:
- Load every item currently in the bin.
- Restore items with no parent reference (ParentId is empty).
- Loop:
- From the remaining items, find any whose parent reference is no longer in the bin.
- Restore each of them.
- If this pass restored nothing, exit the loop.
Items whose parents are still missing after the loop ends remain in the bin. They typically indicate a broken parent chain (for example, the parent was permanently deleted outside the standard flow).
Empty Pseudocode
- Repeat up to three times:
- Load up to all remaining items in the bin.
- Delete items with no parent reference, then items whose parent reference is no longer in the bin.
- If no items remain after this pass, finish.
Each per-item failure is logged and the operation continues.
When the Bin Empties on Its Own
You do not need to run Empty for routine retention. A scheduled background job permanently deletes Recycle Bin items older than 30 days as part of the platform's CronJob pipeline. The job:
- Targets items with creation date older than 30 days.
- Processes in batches of about 200 per loop.
- Caps total run time at approximately 2 minutes per scheduled run; remaining items defer to the next run.
- Uses per-item delete so business logic and related-record cleanup execute for each removal.
- Logs an informational message when the time cap is reached and how many items were deleted.
Manual Empty is most useful when you need the bin cleared sooner than the next scheduled run — for example, after a large test cleanup, or to free unique names immediately.
Effect on Unique Names
While a record is in the Recycle Bin, it still occupies its unique name. Trying to create a new record with the same name fails until the bin entry is restored or permanently deleted. The Dashboard surfaces a notification when a unique-name conflict involves an item still in the Recycle Bin.
To free a name:
- If you do not need the old record back: click Del on the row in the Recycle Bin.
- If you want to repurpose the old record: click Restore and then rename it.
Troubleshooting Tips
- If Restore appears to do nothing, check the system event log for an entity-cannot-be-restored message — the underlying entity may not support soft-delete.
- If Empty never completes for certain items, those items are blocked by database-level constraints. Inspect the event log for the specific foreign-key constraint name, address the blocker, then retry.
- For full symptom-by-symptom resolutions, see Recycle Bin Troubleshooting.
<< Recycle Bin Checklist | Recycle Bin Troubleshooting >>