Mapping of Class field in cmdb_ci table

Jithin2
Tera Contributor

Hi All
I am facing an issue while trying to map the field class. The above field is present in "cmdb_ci" table but it is not coming on Field maps. How can we get the Class field on Field Maps? Did anyone face such an issue?

4 REPLIES 4

mukesh_itsm
Kilo Contributor

Hi,

You will not get some of the system defined field e.g(sys_id, sys_class_name or class). if you want to use this field in your mapping assist then you have to write scripts for that so check run scripts and write some scripts according to your requirements.


prdelong
Kilo Guru

If you are importing from a spreadsheet or external CMDB, you'd like to be able to set class on import and avoid manual cleanup. Here is an example from the OOB SCCM 3.0 integration:

function determineClass() {
// Determine the class of the target CI
if (source.u_v_gs_system_systemrole0 == "Workstation")
target.sys_class_name = "cmdb_ci_computer";
else
target.sys_class_name = "cmdb_ci_win_server";
}

Since this is SCCM, the only two real classes needed are computer, which holds all workstations and laptops, and Windows Server (cmdb_ci_win_server), which is going to hold all of your Windows servers. If your external source has other OS types, those can be easily inserted into this script below:

I like to use .indexOf() instead of a direct string match because it allows to match on part of the string instead of the entire string value.

function determineClass() {
// Determine the class of the target CI
if (source.u_os.indexOf("Windows") > -1 && source.u_os.indexOf("Professional") > -1) // -1 indicates no match in string
target.sys_class_name = "cmdb_ci_computer";
else if ( source.u_os.indexOf("Windows Server") > -1)
target.sys_class_name = "cmdb_ci_win_server";
else if ( source.u_os.indexOf("Red Hat") > -1 || source.u_os.indexOf("CentOS") > -1 || source.u_os.indexOf("Debian") > -1 )
target.sys_class_name = "cmdb_ci_linux_server";
else if ( source.u_os.indexOf("HP-UX") > -1)
target.sys_class_name = "cmdb_ci_hpux_server";
else
target.sys_class_name = "cmdb_ci_server";
}


Jithin2
Tera Contributor

Thanks everyone for the answers. Expecting more answers.


Did you find the Solution?