Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need to modify the field script

suuriyas
Tera Contributor

HI Community,

 

I have written a field script in transform map, when class is t/a/ga/e then it should update as 'e'  which is working fine but when there is empty value from source then it should not update as e or ext currently i guess it if the class is empty then it is updating as ext but it should update as empty 

 

How can i modify the script:

answer = (function transformEntry(source) {

   
    var zone = source.u_employee_class; // (u_employee_class is the field in source table)
    if (zone == "T" || zone == "A" || zone == "GA" || zone == "E") {
        return "E";
    } else
        return 'EXT';

})(source);
10 REPLIES 10

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

Something like this:

 

answer = (function transformEntry(source) {

   if (source.u_employee_class) {.     //when source.u_employee_class is not empty
    var zone = source.u_employee_class; // (u_employee_class is the field in source table)
    if (zone == "T" || zone == "A" || zone == "GA" || zone == "E") {
        return "E";
    } else
        return 'EXT';
}
})(source);

HI @sergiu_panaite 

 

Thanks for the response, i tried this but it did not worked

Maybe try:

 

if (source.u_employee_class.toString()) {

answer = (function transformEntry(source) {

    var zone = source.u_employee_class; // (u_employee_class is the field in source table)
    if (zone == "T" || zone == "A" || zone == "GA" || zone == "E") {
        return "E";
    } else if (zone == " "){
        return ' ';
}else
 return "EXT";
}
})(source);

HI @sergiu_panaite ,

 

Can try something like this will it work?