The CreatorCon Call for Content is officially open! Get started here.

transform script error

Deepthi13
Tera Expert

please correct this code, i am getting empty watchlist

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var watchList = [];
var activeEmail = source.u_data_identify_active_email_;
var nonEmail = source.u_data_identif_ive_non_email_;
var email = source.u_data_identify_email_;
gs.info("@@@ "+activeEmail+"    "+nonEmail+"        "+email);
if(activeEmail == true){
    watchList.push("2fe56c168796e1d01436877d0ebb352d");//Active Email- 2fe56c168796e1d01436877d0ebb352d
}
else if(nonEmail == true){
    watchList.push("509032d647131518ec2ae757436d432a");//Non Email- 509032d647131518ec2ae757436d432a
}
else if(email == true){
    watchList.push("2fe56c168796e1d01436877d0ebb352d");//Email- 5fcfe2da47131518ec2ae757436d433f
}
target.u_identify_data_media = watchList;
gs.info("@@@1 "+watchList);

})(source, map, log, target);
1 ACCEPTED SOLUTION

SanjivMeher
Kilo Patron
Kilo Patron

You should stringify the array like watchList.toString() to set a list field. I would also suggest not hard coding with sysids.

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var watchList = [];
var activeEmail = source.u_data_identify_active_email_;
var nonEmail = source.u_data_identif_ive_non_email_;
var email = source.u_data_identify_email_;
gs.info("@@@ "+activeEmail+"    "+nonEmail+"        "+email);
if(activeEmail == true){
    watchList.push("2fe56c168796e1d01436877d0ebb352d");//Active Email- 2fe56c168796e1d01436877d0ebb352d
}
else if(nonEmail == true){
    watchList.push("509032d647131518ec2ae757436d432a");//Non Email- 509032d647131518ec2ae757436d432a
}
else if(email == true){
    watchList.push("2fe56c168796e1d01436877d0ebb352d");//Email- 5fcfe2da47131518ec2ae757436d433f
}
target.u_identify_data_media = watchList.toString();
gs.info("@@@1 "+watchList);

})(source, map, log, target);

You  


Please mark this response as correct or helpful if it assisted you with your question.

View solution in original post

2 REPLIES 2

SanjivMeher
Kilo Patron
Kilo Patron

You should stringify the array like watchList.toString() to set a list field. I would also suggest not hard coding with sysids.

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var watchList = [];
var activeEmail = source.u_data_identify_active_email_;
var nonEmail = source.u_data_identif_ive_non_email_;
var email = source.u_data_identify_email_;
gs.info("@@@ "+activeEmail+"    "+nonEmail+"        "+email);
if(activeEmail == true){
    watchList.push("2fe56c168796e1d01436877d0ebb352d");//Active Email- 2fe56c168796e1d01436877d0ebb352d
}
else if(nonEmail == true){
    watchList.push("509032d647131518ec2ae757436d432a");//Non Email- 509032d647131518ec2ae757436d432a
}
else if(email == true){
    watchList.push("2fe56c168796e1d01436877d0ebb352d");//Email- 5fcfe2da47131518ec2ae757436d433f
}
target.u_identify_data_media = watchList.toString();
gs.info("@@@1 "+watchList);

})(source, map, log, target);

You  


Please mark this response as correct or helpful if it assisted you with your question.

got solved by just giving 

watchList.toString(","); at end. thanks.