Issues Transforming String to Boolean on Transform Map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 02:40 PM
Hello all,
I'm having some trouble getting string TRUE and FALSE fields mapping to their Boolean counterparts as part of their transform map. They won't map directly, so I've been trying various script versions (both as a before as well as directly on the field map) including things like:
answer = (function transformEntry(source) {
if (source.u_released.toLowerCase() == "yes") {
return true;
if (source.u_released.toLowerCase() == "no") {
return false;
})(source);
and
if (source.field == "t" || source.field == "1") {
answer = true;
if (source.field == "f" || source.field == "0") {
answer = false;
The only thing that appears to happen is the incoming .csv has the values in all caps, but it's being brought in as "True" and "False". Any thoughts, ideas, assistance from the community?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 05:16 PM
Please check below to see if it works:
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 05:18 PM - edited 07-30-2024 05:35 PM
Hi @Erik Nelson
Have you tried toUpperCase instead of toLowerCase?
Also, on your script, you are passing the function to the variable answer.
But is not returning the answer itself.