Transform map script check if contains string
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 08:38 AM
Hi,
I need my transform map to check if a column contains the string 'First Name' and if It is a yes, change first_name field to true. My script is not working.
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (source.u_consumer.indexOf('First Name') > -1)
{
target.first_name = true;
}
})(source, map, log, target);
Can someone help me with this?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 08:42 AM
Hi
You're not updating the column value
place it at the last target.update();
Please mark my answer as helpful/correct, if applicable.
Best regards,
Sai Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 08:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 09:09 AM
Hi again Sai Kumar and Pranesh,
I tried using both but it didnt work.
I have this excel:
This is my map:
When I try to transform with this script:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
if (source.u_consumer.indexOf('First Name') > -1)
{
target.first_name = true;
target.update();
}
})(source, map, log, target);
The field first_name of the target table is not getting updated :S
Do you have any more solutions?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 09:18 AM
May I know are you using onBefore or onAfter transform script?
If its not onAfter() use onAfter with the above script