Importing CI relationships cmdb_rel_ci

Philip Hulshize
Tera Contributor

Here is my problem with importing relationships.

Many times, the server and the VM instance have the same name. So, when I go to import through a transform, I have no control over where this goes. I have the same issue when association a Business Capability to a Business Application or a Business Service. I cannot control which CI it chooses.

Suggestions?

1 ACCEPTED SOLUTION

Swapna Abburi
Mega Sage
Mega Sage

Hi @Philip Hulshize 

In Transform map, you may use Source script for mapping Source field to Target field. In Source script, get the CI from specific CI class using a simple script. ex: cmdb_ci_hardware

View solution in original post

2 REPLIES 2

Swapna Abburi
Mega Sage
Mega Sage

Hi @Philip Hulshize 

In Transform map, you may use Source script for mapping Source field to Target field. In Source script, get the CI from specific CI class using a simple script. ex: cmdb_ci_hardware

For anyone looking for the scripts. For the target of Child to maps to the services table:
answer = (function transformEntry(source) {     
  var gr = new GlideRecord('cmdb_ci_service');
  gr.addQuery('name',source.u_service);
  gr.query();
  if(gr.next()){
    return gr.sys_id;
  } })(source);

 

To map the Parent to the Business Capabilities Table:
answer = (function transformEntry(source) {     
  var gr = new GlideRecord('cmdb_ci_business_capability');
  gr.addQuery('name',source.u_capability);
  gr.query();
  if(gr.next()){
    return gr.sys_id;
  } })(source);

 

I will probably add an onBefore script as I want to be certain not to create anything in the child or parent record