Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2026 08:59 PM
Hello @Saswat4 , I hope you're doing great!
Records created via UI in scoped apps can't be deleted via TABLE API (due to scoped app restrictions), requiring manual UI deletion which is time-consuming.
Solution: GlideRollbackContext API
Use GlideRollbackContext to track and rollback records created during test runs:
// Start tracking changes var rollbackContext = new GlideRollbackContext(); rollbackContext.start(); // Your test code that creates records via UI // (records are automatically tracked) // At the end of test, rollback all changes rollbackContext.rollback();
// Start tracking changes var rollbackContext = new GlideRollbackContext(); rollbackContext.start(); // Your test code that creates records via UI // (records are automatically tracked) // At the end of test, rollback all changes rollbackContext.rollback();
Key Points:
- Automatically tracks all records created during the context
- Works with scoped apps (bypasses TABLE API restrictions)
- Batch deletion – much faster than iterating through UI
- Rollback scope – only affects records created within the context
Alternative Approach:
If GlideRollbackContext doesn't fully meet your needs, consider:
- Create a custom cleanup script that runs as admin/system user with elevated privileges
- Use Business Rules to auto-delete test records based on a flag field
- Leverage ServiceNow's test data management features if available in your instance
Best Practice: Mark test records with a unique identifier (e.g.,
test_run_id) so cleanup scripts can identify and delete them in batches.This approach is much more efficient than manual UI deletion for automated test cleanup.