- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2014 04:15 PM
We are using a test/sandbox instance and are very new to the platform. We have imported a large number of users, but now need to remove some of them. Please describe how I can bulk delete users based on the domain name of their email address (or other criteria if it is simple). We're looking to delete about 6500 users.
Thank you
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2014 08:30 PM
var user = new GlideRecord('sys_user');
user.addQuery('email','CONTAINS','enter_your domain');
user.setLimit('7000'); // Set limit so the query does not delete more users
user.query();
gs.log('Number of users to be deleted-->'+user.getRowCount());
while(user.next())
{
user.deleteRecord();
}
Check the above log before you actually delete the users to confirm if the query is working fine. Run the above script in background script.
Hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-02-2016 02:06 AM
Hi Andrew,
my experience is that setLimit will be ignored by deleteMultiple. For your example it means all user which match the query will be deleted and not only the first 7.000.
Best regards
Dirk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-01-2014 09:56 PM
Just to add to what Bhavesh said, you can also put in a identifier in the log for filtering purposes on the message.
Also it is suggested that do not delete 6500 records at one go as it might cause performance issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2014 01:39 PM
This worked great. Thank you.