Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Importing new rows using Transform Map, but trying to ignore duplicates and updates

AndyMaier
Giga Contributor

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.  

 

transform map.jpg

 

 

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

13 REPLIES 13

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.


AndyMaier
Giga Contributor

I will check my excel file for spaces.   There are no date/time fields in my input excel file.



imput excel file.jpg


Is it the blanks that are causing issues?   If so there is a check box for "" that you may need to check.


AndyMaier
Giga Contributor

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;
}



transform history.jpg



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?


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?