The CreatorCon Call for Content is officially open! Get started here.

Transform Map with condition

kironk
Tera Contributor

I am trying transform map for cmdb_rel_ci . however, I would like to map Child ci from only "windows Server" or "Linux Server" class and NOT from Vmware instance or Nutanix virtual machine instance where you might find the same ci name.

How do I do that , I tried adding cmdb_ci_win_server under reference field value name but no luck 😞

3 REPLIES 3

Tony Chatfield1
Kilo Patron

Hi, with no clear details of your configuration in your post, the community can only guess at your issue.

You are creating an cmdb_rel_ci record via import\transform and you need to ignore\avoid some of the imports based on cmdb_ci class name?

I suspect you would need to use a before transform script to validate the class of your child CI,
but this is a guess based on the little detail provided.

 

Perhaps you could update this thread with clear details of your configuration and issue?

for cmdb_rel_ci , I am trying to map a server to a business application CI.

Since discovery is enabled , I have server with same name under windows server class as well as vmware virtual machine instance . I would like to map the windows server to Business Application (runs on::runs) .

cmdb_rel_ci doesnt have child_class as transform map field to define the class. so my question is , I have child, parent , type and child_class and Parent_class in Soure table to defien the class of the child and parent. 

How do I ensure that the child and parent are mapped to the appropriate class defined in source data.

Peter Bodelier
Giga Sage

Hi @kironk,

 

As Tony already mentioned, please provide some more details in the future to receive better/faster answers.

 

I think you should use field scripts to get the right CI:

 

answer = (function transformEntry(source) {

    var child = new GlideRecord('cmdb_ci_server');
    child.addQuery('sys_class_name', 'cmdb_ci_windows_server').addCondition('sys_class_name', 'cmdb_ci_linux_server');
    child.addQuery('name', source.child);
    child.query();
    if (child.next()) {
        return child.getUniqueValue();
    } else {
        return '';
    }
})(source);

PeterBodelier_0-1698610716776.png

 


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.