- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2017 12:37 PM
We have changed our email domain and now I need to update all of my users. I would like to run a script that would find all of the @olddomain.com and replace it with @newdomain.
Can anyone assist me with this?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2017 12:42 PM
Hello Phil,
Here you go. Please run this from background script. Try this on your dev instance first.
var gr = new GlideRecord('sys_user');
gr.query();
while(gr.next())
{
var str = gr.email;
var res = str.replace("@olddomain.com", "@newdomain.com");
gr.email = res;
gr.setWorkflow(false);
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2017 04:50 AM
Yea, I did.
Here is something really strange though. I have updated the email addresses associated with the users but system notifications using field "caller_id" are still sending emails to the old domain.
I am really stumped here. There are zero references to the old domain in the system at this point...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-16-2017 05:18 AM
Hi Phil,
Have you checked the Email properties to ensure the instance is referencing the right domain there?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2017 12:42 PM
Hello Phil,
Here you go. Please run this from background script. Try this on your dev instance first.
var gr = new GlideRecord('sys_user');
gr.query();
while(gr.next())
{
var str = gr.email;
var res = str.replace("@olddomain.com", "@newdomain.com");
gr.email = res;
gr.setWorkflow(false);
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2017 06:12 AM
Phil,
Glad to see that you are using the Community to learn more.
The Customer Experience team is striving to ensure that customer queries posted from the HI Service Portal are answered in timely and accurate fashion.
If you feel your question has been resolved, please mark the appropriate reply in the thread as being the Correct Answer.
This enables other customers to learn from your thread.
Thank you in advance.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Regards,
Teena Singh
Customer Experience: UX Strategy and Customer Insights
teena.singh@servicenow.com
ServiceNow