Import set - Facing issues with True/False values being set.

muktha1
Tera Guru

Hi Friends,

I have an urgent import to be made. The source data if it contains field with value "TRUE"  in capital letters it does not get imported in the target table in the mapped field. I have been facing this issue. Even after checking the values using the below "On before script and then importing it does not get set. Can anyone please suggest what needs to be done? 

if(source.u_present == "TRUE" || source.u_present == 'True' || source.u_present == 'true')
        {
        source.u_present = "true";      
        }

 

Thanks 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Muktha,

you can use field map script for this; and use below script

answer = (function transformEntry(source) {

if(source.u_present == "TRUE" || source.u_present == 'True' || source.u_present == 'true')
	return true; // return the value to be put into the target field
else
return false;

})(source);

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Priya Shid1
Kilo Guru

Hi Mukta,

true and false are the values having type boolean.If you use it in single quote or double quote it will be consider as string type.so,please check that in condition you used if it works.

 

Please mark if that help you!!

Ct111
Tera Sage

You can code something like this.

 

var str = source.field_name;

var result = str.search(/true/i);

if(result != -1)

{

 

return true;

 

}

 

else {

return false;

}

 

Mark my ANSWER as CORRECT and also HELPFUL if it works.