How to NULL a value in a tMap Expression if it's over a certain character length. I need to trim values that are to long so the values don't truncate

Highlighted
Seven Stars

How to NULL a value in a tMap Expression if it's over a certain character length. I need to trim values that are to long so the values don't truncate

Hello Team of Talend Experts,

 

I need the syntax for a tMap Expression using Java Script that will NULL a value if it's over a certain character length say 30 characters. Also leave the other values under 30 characters the same and it's just a 1 for 1 mapping for the rest of the values.

 

Some Java Script Syntax example would be greatly appreciated


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: How to NULL a value in a tMap Expression if it's over a certain character length. I need to trim values that are to long so the values don't truncate

On tMap right side use thé following expression for each concerned field:
row1.fieldname == null ||
row1.fieldname.length() > 30 ? null : row1.fieldname

TRF

All Replies
Fifteen Stars TRF
Fifteen Stars

Re: How to NULL a value in a tMap Expression if it's over a certain character length. I need to trim values that are to long so the values don't truncate

On tMap right side use thé following expression for each concerned field:
row1.fieldname == null ||
row1.fieldname.length() > 30 ? null : row1.fieldname

TRF
Seven Stars

Re: How to NULL a value in a tMap Expression if it's over a certain character length. I need to trim values that are to long so the values don't truncate

Thanks @TRF  Solution Worked!

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Have you checked out Talend’s 2019 Summer release yet?

Find out about Talend's 2019 Summer release

Blog

Talend Summer 2019 – What’s New?

Talend continues to revolutionize how businesses leverage speed and manage scale

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog