How do I import a set of Locations from CSV and still maintain Parent Reference?

snow_hard252
Kilo Contributor

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.

location_hierarchy.PNG

Could some body help?

Thanks

Hardy

1 ACCEPTED SOLUTION

sumukh
Kilo Expert

Hi Hardy,



This can be easily done through transform maps in one go. You'll need couple of things in the data:



  1. 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
  2. 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 fieldTarget fieldCoalesce
u_namenamefalse
u_parentparentfalse
u_loc_codeu_loc_codetrue


You don't have to write even a single line of code.



Hope this helps.



Thanks.


View solution in original post

5 REPLIES 5

Hi Sumukh



Thanks for advice.



Regards


Hardy