Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

can you try in transform script

 

find_real_file.png

joshvanharn
Kilo Guru

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?

Joao Carlos1
Tera Guru

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.