Bulk Changing Users Email Domain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2018 07:21 AM
Hello,
I'm currently working on an email domain migration project and I'm looking into how I can change all the users on ServiceNow in bulk. I have searched around for a way to bulk update users but I cannot find anything. Before I go ahead and change all the users manually I thought I'd ask on here for some advice. If you know of a way to bulk change users email domain on ServiceNow I would really appreciate the knowledge.
For example I'd like to take all the users who are like so:
John.Doe@old.com
And change them all to a different domain like so:
John.Doe@new.com
Thanks, Ben
- Labels:
-
Communities
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-18-2018 12:01 PM
Hi, I think the domain change is fairly simple via a background script to update sys_user and also cmn_notif_device records
But if you use email address as 'user_name' you should also assess for any function where you reference sys_created_by or sys_updated_by fields, as there could be impact as these will no longer match the user.
For the update find matching records, iterate through them and for each record grab anything before ‘@’ using substring and indexOf
- lastIndexOf if your data contains multiple @ (which is not common for email addresses but I think I read somewhere that it was valid)
something like (untested)
var userUpdate = new GlideRecord(‘sys_user’);
userUpdate.addEncodedQuery(‘emailENDSWITH@example.com’);
userUpdate.query();
while(userUpdate.next())
{
userEmail = userUpdate.email;
userName = userEmail.substring(0, userEmail.indexOf('@') );
userUpdate.email = userName + 'yourNewDomain';
//I'd also add some logging, just incase
userUpdate.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2018 02:54 AM
Hello Tony,
Thanks for your advice it seems fairly easy to do but I have a few more questions. We're doing a batch migration so ideally I need to change ServiceNow email domains for a specific set of users. From what I gather ServiceNow background scripts use Java? Would I therefore be able to use FileInputStream to view an Excel spreadsheet and only change the email domain for the users in that spreadsheet?
Thanks, Ben
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2021 09:18 AM
Did u got any update on this?