The CreatorCon Call for Content is officially open! Get started here.

Background script to modify a User Name

tanumoy
Tera Guru

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?

6 REPLIES 6

Nikhil Dixit
Giga Expert

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

|www.DxSherpa.com|

 

 

 

"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".