Using GlideRollbackContext API for records created via UI
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
we have some playwright tests, where we create some records using UI. However, the records created are in scoped apps, hence, our record cleaner, which uses TABLE API to delete the test data/records created during the test run, is not able to delete them (for obvious restrictions on scoped apps). The only way for us is again deleting via UI. But that takes a lot of time to iterate over all the records (login as admin, navigate to respective table list view and then delete via UI action).
What I am looking for, is there a way I can use GlideRollbackContext API to track the records created during the test runs and then rollback (delete) them in batches. Have been looking but haven't yet found any suitable way of doing it. Appreciate your suggestions and pointers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @Saswat4 , I hope you're doing great!
// 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();
- 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
- 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
test_run_id) so cleanup scripts can identify and delete them in batches.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hello @Rafael P Highly appreciate your response !
I have an evaluation app in a complete separate repo and it is a typescript app. This runs against an instance which contains the scoped apps. I am using playwright tests to evaluate the apps with diff tests and in the process creating some records via UI. Now, had it been a deployable plugin/app, I could have easily used GlideRollbackContext API. Had it been java plugin, I could have used RollbackContext. But you see my limitation with the typescript app not deployed to instance ?
