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

Transform script to trim unwanted space on the target record

Tamil5
Tera Expert

Hi All,

Currently i'm populating cmn_location table using Scheduled job & transform map.

The incoming data some times having unwanted space at the end (eg, loc1 ,loc 2 ,loc3 like wise).

I just need to trim this blank space & insert the correct value into target table.Though it can be done from Business Rule, I have been asked to specifically do with Transform script.

I have tried the below in 'onBefore' Transform Script but its not working.

if(source.u_site_code != '' && source.u_site_code != null && source.u_site_code != 'n/a')

target.u_site_code = (source.u_site_code).toString().trim();

if(source.u_street != '' && source.u_street != null && source.u_street !='n/a')

target.street = (source.u_street).toString().trim();

if(source.u_city != '' && source.u_city != null   && source.u_city != 'n/a')

target.city = (source.u_city).toString().trim();

Any idea would be appreciated. Thanks in advance

Prici

1 ACCEPTED SOLUTION

Tamil5
Tera Expert

Thank you all for your responses.


Actually am able to achieve the same by writing script on field rather onBefore script.


Just clicked on the source field & checked 'Use source script'



find_real_file.png


Its working as expected.


View solution in original post

5 REPLIES 5

Tamil5
Tera Expert

Thank you all for your responses.


Actually am able to achieve the same by writing script on field rather onBefore script.


Just clicked on the source field & checked 'Use source script'



find_real_file.png


Its working as expected.