Importing relationships- reference field value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2014 02:57 PM
In an effort to get our CI data in SNOW configuration management , we successfully identified critical CIs from old system and imported CIs into SNOW CMDB tables Now our team wants to import relationships to cmdb-rel-ci table from external source- CSV template extract.We have verified relationship type exists in cmdb-rel-type . But while trying to come up with a web service import set and transform map , we ran into challenges identifying whether its the tablename or the CI name that should be mapped in parent and child fields - so is it the CI name or CI's table name .if its the CI name - say VMserverC23 , is a script required for the parent and child field on the web service transform map to check that specific CI data being imported exists in their original tables? what is reference field value on transform maps?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2014 08:25 PM
Your excel should contain 5 fields :
- Child Name
- Child Class
- Relationship Type
- Parent Name
- Parent Class
In your transform map, you will just map one field i.e. Relationship type
Rest of the mapping will be done in OnBefore transform script :
on Before transform script :
if (source.u_child_class != '' && source.u_child_name != '' && source.u_parent_name != '' && source.u_parent_class != '')
{
var gr= new GlideRecord('source.u_child_class');
gr.addQuery('name','source.u_child_name');
gr.query();
if (gr.next()) {
target.child = gr.sys_id;
}
var gre = new GlideRecord('source.u_parent_class');
gre.addQuery('name','source.u_parent_name');
gre.query();
if (gre.next()) {
target.parent = gre.sys_id;
}
}
Regards,
Bhavesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2017 10:49 AM
Hey I just tried your script.
got errors so after a look:
- gr.addQuery('name','source.u_child_name');
should be:
- gr.addQuery('name',source.u_child_name);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2022 04:50 AM
Hi
Did it work for you ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2022 04:39 AM
Hi
I went through your this solution, I made the excel same way as you but it made relationship which has only populated relationship type and empty child and parent name and class.
I ran it from admin level.
My excel:
my services:
relationships:
script: