Transform map - import data to a field type of boolean

Indira8
Kilo Sage

Hi All,

We have a transform map where we need to import data from excel to a table. There is one column in the excel which has values either 'TRUE' or  empty value. We need to map this to a field which id boolean type. Could you please let me know where there is error in the below script:

 

answer = (function transformEntry(source) {

// Add your code here
//return ""; // return the value to be put into the target field
if (source.u_disabled == "true" || source.u_disabled== "TRUE") {
answer = true;
}

if (source.u_disabled == "" || source.u_disabled == "FALSE") {
answer = false;
}
})(source);

 

Thank you 

1 ACCEPTED SOLUTION

Muhammad Khan
Mega Sage

Hi indra,

 

Try the following script;

answer = (function transformEntry(source) {

// Add your code here
if (source.u_disabled == "true" || source.u_disabled== "TRUE")
    return true; // return the value to be put into the target field
else if (source.u_disabled == "" || source.u_disabled == "FALSE")
    return false; // return the value to be put into the target field

})(source);

 

Hopefully this will work.

View solution in original post

2 REPLIES 2

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Indira, Please make sure the column name is correct and also include log statements to print the output and check if the If loop is getting executed or not. Also, assume you are using the main transform script field?

Muhammad Khan
Mega Sage

Hi indra,

 

Try the following script;

answer = (function transformEntry(source) {

// Add your code here
if (source.u_disabled == "true" || source.u_disabled== "TRUE")
    return true; // return the value to be put into the target field
else if (source.u_disabled == "" || source.u_disabled == "FALSE")
    return false; // return the value to be put into the target field

})(source);

 

Hopefully this will work.