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

Hi Muktha,

Can you share the updated field map script and also how the incoming value looks like; add some logs to check what the incoming value is; on safer side you can convert the incoming value to lower case and then compare

the conversion to lower case will handle below values TRUE, True, TRue, TrUE, true, TRue etc

answer = (function transformEntry(source) {

var incomgingValue = source.u_present;
gs.info('Incoming value is: ' + incomgingValue);

incomgingValue = incomgingValue.toLowerCase();

if(incomgingValue == 'true')
return true; // return the value to be put into the target field
else
return false;

})(source);

Regards
Ankur

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

@muktha 

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

Thanks!
Ankur

 

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

Hi Muktha,

Any update on this?
Can you mark answer as correct, 👍 helpful if you were able to achieve the requirement. This enables other members to learn from this thread.

Regards
Ankur

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

Azim Kazi
Giga Guru

Hello Muktha,

You just Convert that "true" "false" string first(upper/lower) then assing to that field using function you can convert

current.short_description.toUpperCase(); or
current.short_description.toLowerCase(); 

do this in field map only I sure it will work.


if my response helps you then kindly mark my answer helpful and correct otherwise if any query feel free to ask further.

 

Regards,

Ajim.

and make sure when assigning true/false value don't use double or single quotes as I saw you written  

source.u_present = "true";   wrong

source.u_present = true;  right