Background script to modify a User Name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2018 01:39 AM
Suppose a User "ABC" is present in multiple fields of multiple tables within the instance. I want to replace "ABC" with "XYZ" in all those fields of all the tables at one go with a background script.
Can anyone help on this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2018 02:49 AM
Hi Tanumoy,
If you want to check more than one user those are referred by distinct fields of tables in instance and replace existing value with desired one than refer following script for the same.
var gr = new GlideRecord('sys_user');
gr.addQuery('name','ABC');
gr.query();
while(gr.next())
{
if(gr.name == 'ABC')
gr.first_name = 'XYZ';
gr.last_name = "'';
gr.name = gr.first_name + gr.last_name;
gr.update();
}
Please mark answer correct and helpful based on the response.
Regards,
Nikhil Dixit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2018 03:38 AM
"ABC" and "XYZ" are two different user. I don't want to change the name of "ABC" to "XYZ". I just want to replace the "ABC" from all other referenced table with "XYZ".