Transform map: How to handle boolean values?

Arthur7
Tera Contributor

Hi All,

 

Does anyone know how to handle boolean values??

 

I want to import users from excel file including   target "active" field in the user table. I have created below script, but i don't know why is does not working correctly?.
Source field has a string format.

 

if (source.u_active == 'true') {  

  target.active = true;  

} else if (source.u_active == 'false') {  

  target.active = false;

}

obr.png

 

obr2.png

 

I would be grateful for any anwers.

 

Best Regards
Artur

1 ACCEPTED SOLUTION

prdelong
Kilo Guru

All you should have to do is change 'target.active = true' to 'answer=true' (same with false).



However, I agree with Mark. That is something probably best addressed in the script field.


View solution in original post

3 REPLIES 3

Mark Stanger
Giga Sage

I think the problem is that you are using the 'Source script' functionality (which is intended to set a value back to the 'source' field.   If you moved your script into the main transform map 'Script' field I think it would work better.


prdelong
Kilo Guru

All you should have to do is change 'target.active = true' to 'answer=true' (same with false).



However, I agree with Mark. That is something probably best addressed in the script field.


Arthur7
Tera Contributor

Thank you both!!!, I have used "answer' instead of " target" and now it's working as I expected.