We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Onbefore script to remove duplicates from import table

jackinsidend
Tera Guru

I have an jdbc connection that pulls in about 8000 records, I want to process all that are not duplicates.

I have a serial number field, I would like to not even write the duplicated to my import set table. Is this possible in an onbefore script?

Thanks,

Jack

6 REPLIES 6

Nikhil Pandit
Mega Guru

Hi Jack

You can write transform script like:

if(operation== 'update'){

ignore=true;

}

jackinsidend
Tera Guru

I ended up doing an onbefore script:

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

if(source.u_biosserialnumber == '' || source.u_biosserialnumber == null || source.u_biosserialnumber == '0' || source.u_biosserialnumber == 'INVALID' || source.u_biosserialnumber == 'N/A' || source.u_biosserialnumber == 'System Serial Number' || source.u_biosserialnumber == 'To be filled by O.E.M.'){

ignore = true;
} else {

var count = 0;

var findHW = new GlideRecord('alm_hardware');
findHW.addQuery('model_category', "81feb9c137101000deeabfc8bcbe5dc4");
findHW.addQuery('serial_number', source.u_biosserialnumber);
findHW.query();

while (findHW.next()){
count = count + 1;
}
if (count > 1){
ignore = true;

}

}

})(source, map, log, target);

 

So far so good!