Transfer data from one company to another company in same instance

Asha Pathak
Tera Contributor

In my instance I have two companies having same name but different sys id
I need to transfer only active users from one company to another company by transform map
Please help , how can I achieve this

4 REPLIES 4

Mark Manders
Mega Patron

Why do you need to use a transform map? 

Select all the active users from the 'wrong' company and do an 'update all' on the list and set the correct company.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Bharath24
Tera Expert

If the number of users are less, then you can update the company on the users list. 
If the number of users is high. You can use the following fix script.

var list = new GlideRecord("sys_user");
list.addEncodedQuery("company=<wrong  sys_id of company>");
list.query();
while (list.next()){
    list.setValue("company","<correct sys_id of company>");
    list.update();
}

Community Alums
Not applicable

Hi @Asha Pathak ,

If you want to do in same instance, so please use script there is no need to use transform map. You can write a background script mentioned below 

var userGr = new GlideRecord("sys_user");
userGr.addQuery("company", "sys_id of current company");
userGr.query();
while (userGr.next()){
    userGr.setValue("company", "<sys_id of company you need to change>");
    userGr.update();
}

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak

PrashantLearnIT
Giga Sage

HI @Asha Pathak 

 Script execution is not required here just you need to open all the active users from the incorrect company, then update the list to set the correct company using Update All Context Menu.

 

 

********************************************************************************************************
Please appreciate the efforts of community contributors by marking the appropriate response as the correct answer and helpful. This may help other community users to follow the correct solution in the future.

********************************************************************************************************
Cheers,
Prashant Kumar
ServiceNow Technical Architect


Community Profile LinkedIn YouTube Medium TopMate
********************************************************************************************************