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

Amit Gujarathi
Giga Sage
Giga Sage

HI @dheeru_1994 ,
I trust you are doing great.
ere's a basic example of how you can set the value in the onAfter script. This script assumes that you're trying to set the u_firstname field in the target table based on some condition or value from the source table:

(function runTransformScript(source, map, log, target /* GlideRecord */) {

    // Example condition - modify as needed
    if (source.u_some_field == 'someCondition') {
        target.u_firstname = 'xyz'; // Set the target field value
    }

    target.update(); // Important to save the changes

})();

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // Add your code here
     target.u_firstname='RAJPOOT';


})(source, map, log, target);  i am writing this in on after and i want to update u_firstName field but when i processed everything data is going in target field but not updating field , field value is going same as source value is comming where i am going wrong 
 

@dheeru_1994 This script will not work. If you want without any condition.

As I said above you can try with this: add target field in field map and use script there as return "xyz";

It will work. 

can you write code 

 

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.