- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2015 12:05 PM
Hi,
How do I import a set of Locations from CSV and still maintain Parent Reference?
I have Locations dumped in CSV and have Fields REGION, COUNTRY, STATE.
Just as in cmn_location table, I would like to have this data of locations imported, to have a Hierarchical Display in the Look up List as for Location field in cmdb_ci.
Could some body help?
Thanks
Hardy
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2015 12:44 PM
Hi Hardy,
This can be easily done through transform maps in one go. You'll need couple of things in the data:
- A unique identifier (not sys_id) like a location code. Doing import solely based on plain text is not recommended and more error prone. We will use this as a coalesce field for this transform
- Hierarchy mapped in the data i.e. Parent-Child relationship (As mentioned by Abhiram)
Now while creating the transform map do fieldmaps like this:
Source field | Target field | Coalesce | |
u_name | name | false | |
u_parent | parent | false | |
u_loc_code | u_loc_code | true |
You don't have to write even a single line of code.
Hope this helps.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2015 12:24 PM
The CSV should include another column called "parent" which gives the parent location for a location.
This is two fold. On location table you have something called "parent". This table is a self referencing table meaning a Location will have a location as it's parent.
The transformation need to be done in two steps:
- First you will have to only insert the parent locations ( Meaning Parent = Null)
- Second you will have to process only children, and when you do so write a Transform Script to set the parent( created from step 1)
If you give me some sample data, we can work through it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2015 07:28 PM
HI Abhiram,
Appreciate your response.
To your point CSV should include another column parent, I agree . But I have more than 2500 Physical Locations and Since I have 3 Tier Hierarchy REGION, COUNTRY, STATE, do you mean I need to columnize parent ; parent.parent ; parent,parent.parent ?
Thanks
Hardy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2015 12:44 PM
Hi Hardy,
This can be easily done through transform maps in one go. You'll need couple of things in the data:
- A unique identifier (not sys_id) like a location code. Doing import solely based on plain text is not recommended and more error prone. We will use this as a coalesce field for this transform
- Hierarchy mapped in the data i.e. Parent-Child relationship (As mentioned by Abhiram)
Now while creating the transform map do fieldmaps like this:
Source field | Target field | Coalesce | |
u_name | name | false | |
u_parent | parent | false | |
u_loc_code | u_loc_code | true |
You don't have to write even a single line of code.
Hope this helps.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-15-2015 03:24 PM
I've done this exact same process and just as sumukh stated, the location code is "key". The transform map runs and all data is imported in a single step.