Transform map for cmdb_ci_computer table

Community Alums
Not applicable

Hi,

I have a transform map where serial_number is the coalesce. But we need to avoid duplicates to create based on a custom field "corporate_number. So when importing the records, we need to make sure there is no record that has the same "corporate_number". If there is one, it should not update the record and throw an error. 

How can I achieve this?

For example, 

Serial_number            corporate_number

1234567                      123

7896325                      123

We don't want records like this in CMDB. 

Please assist

Thank you

1 ACCEPTED SOLUTION

Community Alums
Not applicable
Write an onBefore transform script. In the script glide record the using corporate number. If there is any entry that matches with corporate_number you can set ignore to true. (function transformRow(source, target, map, log, isUpdate) { // Add your code here var gr = new GlideRecord("cmdb_ci_computer"); gr.addQuery("corporate_number", source.corporate_number); gr.query(); if (gr.next()) { ignore = true; error=true; error_message='Corporate number duplicate.'; } })(source, target, map, log, action==="update");

View solution in original post

6 REPLIES 6

Sukraj Raikhraj
Kilo Sage

Are you using regular transform or Robust? on the regular transform map, create a lookup script and check if corporate_number already exists. Do this on the onBefore insert. 

Community Alums
Not applicable
Write an onBefore transform script. In the script glide record the using corporate number. If there is any entry that matches with corporate_number you can set ignore to true. (function transformRow(source, target, map, log, isUpdate) { // Add your code here var gr = new GlideRecord("cmdb_ci_computer"); gr.addQuery("corporate_number", source.corporate_number); gr.query(); if (gr.next()) { ignore = true; error=true; error_message='Corporate number duplicate.'; } })(source, target, map, log, action==="update");

Community Alums
Not applicable

This worked. I just needed to change the action from "update" to "insert"

Community Alums
Not applicable

Thank you so much!