Creating dynamic relationship (cmdb_rel_ci)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2016 02:25 PM
Hi All,
I am trying to create relationship in (cmdb_rel_ci) when import the child CIs. I Knew the parent CIs for those child ci .
I am using the type as Connects to::Connected by". It is also available in suggested relationships
I am using the following code in the oncomplete() transform map events.. it is creating relationship ..but with empty Parentid and Child CIs.
var grRel = new GlideRecord('cmdb_rel_ci');
grRel.parent.cmdb_ci.name = 'x.ci'; // Hard coded
grRel.child.cmdb_ci.name = source.name;
grRel.type = "Connects to::Connected by";
inc.insertWithReferences();
Thanks
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-11-2016 07:11 PM
Hi Mike,
I would try to do this with OnBefore transform map script
Also, at line number 3, your assigning import set table field value to cmdb_rel_ci table. Normally, your import set field values are prefixed with u_ since those are custom created tables.So kindly try to change this line as well
- grRel.child.cmdb_ci.name = source.u_name;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2016 03:50 PM
You want to use the sys_id of the relationship type record:
grRel.type = ("sys_id");
Also, try using an onAfter transform script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2016 02:04 PM
I have achieved a similar thing and posted my script to that question - as I need to understand how to coalesce these fields!
transform coalesce via script (cmdb_rel_ci)
I have achieved with a OnBefore... and then I am doing a GlideRecord query to get the sys_id of the parent & child CIs
(I say achieved, I ran it on a test record and babysat it through the processing... now I am running a full discovered relationship map CSV its not quite working! but I think my post may help...)