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 09:26 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 09:35 AM
This might be a permissions issue (e.g. if you aren't in global scope). Try the same, but using the following:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var cust = source.u_consumer.getValue();
if (cust.indexOf('First Name') > -1)
{
target.first_name = true;
}
})(source, map, log, target);
Did you check to see if there might be a case issue? Can you post a raw data example if the above doesn't work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2021 09:35 AM
Ok sorry, besides the onBefore I missed the fact that you actually have to match the other fields in your transform map. For some reason I thought that the script would change it directly in table.