Mapping of Class field in cmdb_ci table

sanasayyad
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? Does scripting is required? Is there any option rather than scripting ?

1 ACCEPTED SOLUTION

Singha8
Tera Expert

Hi @sanasayyad ,

 

Direct Mapping is not possible for sys_class_name in Field Maps.

 

Scripting (Transform Script) is required if you want to set it dynamically.

 

Alternative options include using Business Rules or Data Policies after the data import to update the Class field.

 

Use a Script in the Transform Map (Recommended)

 

You need to create an onBefore Transform Script in your Transform Map:

 

1. Open the Transform Map.

 

 

2. Scroll down to the Field Maps section and click New.

 

 

3. Select the Source Field (e.g., "Class" from your Excel file).

 

 

4. In the Target Field, select sys_class_name.

 

 

5. Check the Use Script box and add the following script:

 

(function transformEntry(source, target, map, log, isUpdate) {

    // Check if the source class value is provided

    if (source.u_class) { 

        target.sys_class_name = source.u_class;

    }

})(source, target, map, log, action);

 

Replace source.u_class with the actual column name from your Import Set table.

Ensure the values in your Excel match the exact class names (e.g., cmdb_ci_server, cmdb_ci_database).

 

Hope this helps! If it does, please mark it as helpful for others facing the same issue.

Thank you,

Ananya 

 

View solution in original post

3 REPLIES 3

Bert_c1
Kilo Patron

Hi,

 

Please be more clear on what you are trying to achieve. What is a "Field Map"? All tables in the cmdb hierarchy have the sys_class_name field, and that is maintained by the platform.

 

Once more details are provided, I expect someone here can assist.

Hi,

I am importing CI data into ServiceNow from an Excel sheet using an Import Set. While creating a Transform Map, I tried to use Mapping Assist to map the "Class" field from my Excel file to the cmdb_ci table. However, in Mapping Assist, the "Class" (sys_class_name) field does not appear as an available target field.

My questions:

1.Why is sys_class_name not visible in the Mapping Assist when selecting the target fields?
2.How can I correctly map and transform this field so that the correct CI class (e.g., "Server") is assigned instead of defaulting to "Configuration Item"?
Any guidance would be appreciated!

Thanks!

Singha8
Tera Expert

Hi @sanasayyad ,

 

Direct Mapping is not possible for sys_class_name in Field Maps.

 

Scripting (Transform Script) is required if you want to set it dynamically.

 

Alternative options include using Business Rules or Data Policies after the data import to update the Class field.

 

Use a Script in the Transform Map (Recommended)

 

You need to create an onBefore Transform Script in your Transform Map:

 

1. Open the Transform Map.

 

 

2. Scroll down to the Field Maps section and click New.

 

 

3. Select the Source Field (e.g., "Class" from your Excel file).

 

 

4. In the Target Field, select sys_class_name.

 

 

5. Check the Use Script box and add the following script:

 

(function transformEntry(source, target, map, log, isUpdate) {

    // Check if the source class value is provided

    if (source.u_class) { 

        target.sys_class_name = source.u_class;

    }

})(source, target, map, log, action);

 

Replace source.u_class with the actual column name from your Import Set table.

Ensure the values in your Excel match the exact class names (e.g., cmdb_ci_server, cmdb_ci_database).

 

Hope this helps! If it does, please mark it as helpful for others facing the same issue.

Thank you,

Ananya