Importing new rows using Transform Map, but trying to ignore duplicates and updates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2014 12:25 PM
4/18/14 ... I have updated my question because I misphrased it. I created an Import Set and Transform Map trying to import new rows from an excel spreadsheet to a Security Access Table. My goal is to only import new rows and not do any updates to existing rows. I can get rows to insert, but I am having problems with my onBefore script trying to check and skip/ignore duplicate rows. If I find a match to the Target table records for u_name & u_func_access_display, I want to skip the record and not insert.
This is my onBefore script:
//CHECK TO SEE IF RECORD ALREADY EXISTS IN THE LLB SECURITY ACCESS TABLE
//COMPARE WITH NAME AND FUNC ACCESS DISPLAY FIELDS
var ast = new GlideRecord('u_llb_security_access');
ast.addQuery('u_name',source.u_name);
ast.addQuery('u_func_access_display',source.u_func_access_display);
ast.query();
//IF RECORD ALREADY EXISTS SKIP THE RECORD AND GO TO THE NEXT
if(ast.next()){
ignore = true;
}
My onBefore script does not skip/ignore any duplicate records. Any ideas on what I am doing wrong?
Thanks,
Andy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2014 11:03 AM
Have you looked at the history of those records that were updated? I have seen this when there are spaces at the end of or start of a value sometimes..
Is one of these a date/time field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2014 11:09 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2014 11:13 AM
Is it the blanks that are causing issues? If so there is a check box for "" that you may need to check.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2014 11:24 AM
Nope, I scripted for those in my onBefore script:
/**
* For variables go to: http://wiki.service-now.com/index.php?title=Import_Sets
**/
//SCRIPTS TO SKIP RECORDS WITH NULL OR EMPTY FIELDS
//NAME FIELD CHECK FOR NULL OR EMPTY
if (source.u_name.nil()){
ignore = true;
}
//FUNC_ACCESS_DISPLAY FIELD CHECK FOR NULL OR EMPTY
if (source.u_func_access_display.nil()){
ignore = true;
}
//FUNC_ACCESS_TECH FIELD CHECK FOR NULL OR EMPTY
if (source.u_func_access_tech.nil()){
ignore = true;
}
//FUNC_ACCESS_DISPLAY DESC CHECK FOR NULL OR EMPTY
if (source.u_func_access_desc.nil()){
ignore = true;
}
//APPROVER_GROUP FIELD CHECK FOR NULL OR EMPTY
if (source.u_approver_group.nil()){
ignore = true;
}
//ACCESS_TYPE FIELD CHECK FOR NULL OR EMPTY
if (source.u_access_type.nil()){
ignore = true;
}
//CHECK TO SEE IF RECORD ALREADY EXISTS IN THE LLB SECURITY ACCESS TABLE
//COMPARE WITH NAME AND FUNC ACCESS DISPLAY FIELDS
//SET COALESCE for U_NAME & U_FUNC_ACCESS_DISPLAY TO TRUE
if(action != "insert"){
ignore= true;
}
The rows with empty fields get ignored, the 2 duplicate rows already in the table get ignored, and the 1 row with the wrong name gets ignored, but the 8 rows new rows I imported before get inserted again?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2014 11:32 AM
You say
2 duplicate rows already in the table get ignored,
Then
but the 8 rows new rows I imported before get inserted again
So are you saying that 8 of the rows that you are importing have duplicates in the file that you are importing?