How to cleanup proliferation of OS choices on cmdb_ci_computer

emyrold
Giga Expert

I have discovered that some transform maps have been creating new OS choices for cmdb_ci_computer or tables extended from computer.

I have figured out a way to prevent this going forward, using by WindowsOSNameHelper().formatWindowsOSName(source.u_operatingsystem) in the related transform maps.   I will need to perform a save-as of the windowsOSNameHelper script include and make a new one for non_windows OS's.

That is fine for my imports going forward, however, I'm a little stumped on how to clean it up all the older duplicate or redundant choices from 25,000 server ci records.

300 Operating System Choices.

- 175 on cmdb_ci_computer

- 107 on cmdb_ci_linux_server

- 45 on u_cmdb_ci_desktop

Let's say I have a the following ci "Erik Server" and this display's for OS: Microsoft Windows Server 2008 R2 64-bit

when I look at the sys_choice table:

cmdb_ci_server has "Microsoft Windows Server 2008 R2 64-bit"

cmdb_ci_win_server also has "Microsoft Windows Server 2008 R2 64-bit"

How do I programatically   delete the cmdb_ci_win_server choice and make sure the ci choice is correctly set to the choice coming from cmdb_ci_computer instead.

Thanks,

-e

1 ACCEPTED SOLUTION

mike_allgire
Giga Guru

Identify the sys_id of the OS that you want to keep, and write a fix script to replace the value on all of the records for the other tables. Once those values are associated to the single OS, then write another fix script to clear the values that are not necessary.



Fix Scripts - ServiceNow Wiki


View solution in original post

3 REPLIES 3

mike_allgire
Giga Guru

Identify the sys_id of the OS that you want to keep, and write a fix script to replace the value on all of the records for the other tables. Once those values are associated to the single OS, then write another fix script to clear the values that are not necessary.



Fix Scripts - ServiceNow Wiki


Hi Mike,



Not sure I'm fully understanding your suggestion...



I'm thinking maybe I just delete all choices that were created and let the new choices rebuild on next import....   maybe I was over thinking this...



-e


That is also a solution if it is accepted by who ever is in control of the governance of that data.