The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Transform map returns undefined value in the field

Miloslav1
Tera Contributor

Hello, I was trying to understand what I might did wrong here.

My goal here is to change only value from "###" to "aaa", the rest of the values should remain untouched.

Unfortunately with this easy function script I am able to change the value "###" to "aaa", but the rest of the fields changed its value to "undefined". Can you please let me know what I am missing here? Thanks in advance.

 

Here is the simple transform map script function:

answer = (function transformEntry(source) {

if (source.u_business_phone == '###' ){ return 'aaa';}

})(source);

Here is the screen from instance before the transform, then the excel sheet with new data and then after the transform is complete.

1 ACCEPTED SOLUTION

Robbie
Kilo Patron
Kilo Patron

Hi @Miloslav1,

 

Based on the script you've provided, you're running this as a script at field level. (Business phone field)

I've made a small tweak to your script to use:

 

answer = (function transformEntry(source) {
if (source.u_business_phone == '###') {
return 'aaa';
} else {
return source.u_business_phone;
}
})(source);

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

View solution in original post

6 REPLIES 6

Shriram Joshi
Tera Guru
Tera Guru

Hi @Miloslav1 - Try the below code and let me know if it works for you. Please mark it helpful if it worked.

answer = (function transformEntry(source) {
if (source.u_business_phone == '###') {
return 'aaa';
} else {
return source;
}
})(source);


BR,
Shriram Joshi

---------------------------------------------------------------------------------------------

Mark this as Helpful / Accept the Solution if this helps.

Hello Shriram, thank you for the reply. I thought that I am missing some brackets, anyway now it is returning this string for the values, which should be untouched.

"object GlideRecord"

Robbie
Kilo Patron
Kilo Patron

Hi @Miloslav1,

 

Based on the script you've provided, you're running this as a script at field level. (Business phone field)

I've made a small tweak to your script to use:

 

answer = (function transformEntry(source) {
if (source.u_business_phone == '###') {
return 'aaa';
} else {
return source.u_business_phone;
}
})(source);

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

Miloslav1
Tera Contributor

Thank you very much, this solves the problem.