Transform map script check if contains string

Joao Carlos1
Tera Guru

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.

7 REPLIES 7

Sai Kumar B
Mega Sage
Mega Sage

Hi @Joao Carlos 

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

Pranesh072
Mega Sage
Mega Sage

are you using onBefore script?

 

find_real_file.png

Joao Carlos1
Tera Guru

Hi again Sai Kumar and Pranesh,

 

I tried using both but it didnt work.

 

I have this excel:

 

find_real_file.png

 

This is my map:

 

find_real_file.png

 

 

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!

May I know are you using onBefore or onAfter transform script?

If its not onAfter() use onAfter with the above script