Transform map script

dheeru_1994
Tera Contributor

HII All i have requirement ,my requirement is i am using transform map script to update or set new value like my target field name is u_firstname  for that on after i am doing 
target.setValue('u_firstname','xyz');

but after completing transformation in my target table nothing is comming even though source field name and target field name are correct any  help 
Note:-  i am very weak in transform script please provide me stuff with code like how to use ,map, source , target 

thanks everyone

 

1 ACCEPTED SOLUTION

In field map add target field you want to set. And check the checkbox for script(field : Use Source Script). Add below code.

 

return "xyz";

 

It will set the target field value you want to set.

 

View solution in original post

12 REPLIES 12

Prince Arora
Tera Sage
Tera Sage

@dheeru_1994 

 

Can you try this:

 

target.u_firstname = "XYZ";

 

 

Also if your mapping is straight forward with the source, you can directly do the mapping like below instead fof write the scripting

PrinceArora_0-1701163924453.png

 

If my answer solved your issue, please mark my answer as  Correct & 👍Helpful based on the Impact.

i want my target table field name is u_firstName , and in my excel sheet field name is FirstName there are four records which are insert like in all four fields FirstName are diffrent when i do all process with this script means all four records FirstName will same which i set in transform map script , target.u_firstname = 'xyz '; 

in all four records xyz will come in target fields if yes then how 

 

AnveshKumar M
Tera Sage
Tera Sage

Hi @dheeru_1994 

If you have this value in source, you can simply do the field mapping instead of writing script. Let me know if you can't use field map and you should only use script.

 

Please check the following documentation for help on field mapping.

https://docs.servicenow.com/csh?topicname=t_CreatingAFieldMap.html&version=latest

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️

Thanks,
Anvesh

Akshata T
Tera Guru

@dheeru_1994 Instead of using On After script, you can add this field in field map and use the 'Use source script' option as below. And use script as return "xyz";

AkshataT_0-1701164508913.png