Transfer data from one company to another company in same instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2024 10:48 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2024 12:30 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2024 12:52 AM
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();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2024 01:07 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-13-2024 01:13 AM
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
********************************************************************************************************