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

Ct111
Tera Sage

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

 

You need to set value in target table and it's field not source table if it's true.

 

Mark my ANSWER as CORRECT and HELPFUL if it helps.

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

muktha1
Tera Guru

I tried it out Ankur,it is not working. The excel data may have "True or TRUE values also. But only when we change the source data excel sheet values to true it gets set in the target table.

Even if we check  the source data for capital TRUE and make it true in the ON before script , it is not getting set. Now I tried with the field map script as you told. Then also it is not getting set. What could be the issue?

Hi,

As per @Ankur Bawiskar said create a field map script on target field.And use some log in it. So that  it is easy to get where the script fail.

answer = (function transformEntry(source) {

if(source.u_present == "TRUE" || source.u_present == 'True' || source.u_present == 'true')
{
  gs.log("In If condition");
  return true; // return the value to be put into the target field
}
else
{
  gs.log("In else");
  return false;
}
})(source);

 

Thanks,

Kunal