How to ignore row when two columns cannot find a reference.

Watwson
Tera Contributor

Requirement:

If it does not find either of the field1 or field2 then the record is ignored.  This is due to the way that the scripts are executed for the individual column, each with their own "ignore" when the column contains an empty value, but the ignore affects the entire record, not just the column.  To fix this we should probably clear the ignore command from the two column scripts and move it to the onBefore script so that if both of the columns have empty values then ignore the record.

 

Current column scripts:

answer = (function transformEntry(source) {
 
// Add your code here
var usr = new GlideRecord("sys_user");
usr.addActiveQuery();
usr.addQuery('user_name', source.field1);
usr.query();
if (usr.next()) {
return source.field1; // return the value to be put into the target field
}
else {
        ignore = true;
}
 
})(source);
 
 
 
 
answer = (function transformEntry(source) {
 
// Add your code here
var usr = new GlideRecord("sys_user");
usr.addActiveQuery();
usr.addQuery('user_name', source.field2);
usr.query();
if (usr.next()) {
return source.field2; // return the value to be put into the target field
}
else {
        ignore = true;
}
 
})(source);
1 REPLY 1

JenniferRah
Mega Sage

Looks like you need an or condition: 

var usr = new GlideRecord("sys_user");
usr.addActiveQuery();
usr.addQuery('user_name', source.field2).addOrCondition('user_name', source.field1);
usr.query();
if (usr.next()) {
    return usr.user_name; // return the value to be put into the target field
} else {
    ignore = true;
}