Duplicate CI entry, inserting from Import Set

prabhur34
Mega Contributor

I am inserting CIs using Web Services into Import Set tables. Transform maps is created to insert it in to different CI classes. After insertion, I am seeing a duplicate entry with class type u_computer_historical in the CI table. Refer the screenshot. CI is inserted into Windows Server, but there is a duplicate at the same time.

Anyone has came across this and what is the solution to remove these duplicates?

find_real_file.png

1 ACCEPTED SOLUTION

prabhur34
Mega Contributor

Hi Dave,



This worked. I had Script within Transform Map which will define the sub-class of a CI record under cmdb_ci_server.


Initially, target table in Transform Maps was cmdb_ci_server. I updated this to cmdb_ci and left the Script in Transform Maps as it is.



Thanks for the hint!


View solution in original post

10 REPLIES 10

andymcdonald
Kilo Guru

If you have a transform map, and you consider the above records duplicates, then you should be coalescing on the name field.   this will cause the import process to treat the name field as the primary key of the records.


Hi Andy,



Fortunately the name field is already a coalesce field. What am I doing wrong?


find_real_file.png


can you check if Name is difference?


meaning: any extra space is there in any of the 2 records in name field value?


because if coalesce is there then transformation should happen based on primary key.


you may also want to check if multiple fields are having coalesce = true in transform map?


Hi Prabhu,



What table are you importing to? If you're importing to cmdb_ci_server but there's a record in u_computer_historical then it won't coalesce.



Is u_computer_historical extending cmdb? If so you can add a business rule to the cmdb table to run before insert with the below script. As long as the name field on both tables is extended from the base cmdb table and you have set business rules to run on your transform map it will reject any duplicates that come in on the import.



var gr = new GlideRecord('cmdb');


gr.addQuery('name',current.name);


gr.query();



if(gr.next()) {


current.setAbortAction(true);


gs.addErrorMessage("A DEVICE WITH THAT NAME ALREADY EXISTS, PLEASE SEARCH THE CMDB BEFORE CREATING NEW RECORDS");


}