- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 04:12 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 07:06 AM
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'
Its working as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 04:31 AM
Hi Prici,
Could you please use the below sample code to remoe unwanted spaces:
var str = "PB 10 CV 2662";
str = str.split(" ") //[ 'PB', '10', 'CV', '2662' ]
str = str.join("");
gs.print(str);
Let me know if this was helpful/correct
Have a great day ahead
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 04:55 AM
Hi Prici,
In your script you are using () on source object , please remove them and then try. Pfb the updated script
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();
Mark this correct, if it suites your requirement
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 05:28 AM
Hi Guys,
Actually the trim operation is working fine regardless of with/without the braces.
But the trimmed value is not getting updated in the target table.
Even I tried giving target.insert or target.update. But with this, duplicate records inserted.
One record contains only this values(3 fields site code,street,city), another one contains value for other fields (state,Region & etc)
If I don't give these statement, i'm not getting duplicates & at the same time not getting trimmed values
Thanks
Prici
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2017 05:35 AM
Hi Prici,
Have you deleted the manual field mapping for those fields which you were using in transform script, If not then please update the filed mapping using mapping assist.