[resolved] StringHandling function in tMap

Highlighted
One Star

[resolved] StringHandling function in tMap

Is there a way that I can use the StringHandling function from tMap in other place?
For example,
I've got this expression typed in tFileCopy, basic settings -> rename -> destination filename
StringHandling.LEFT(globalMap.get("FILE_NAME"),(StringHandling.LEN(globalMap.get("FILE_NAME"))-4))+"_"+TalendDate.getCurrentDate()+".jpg"
But it returned error sort like "LEN in StringHandling method not applicable". While the TalendDate function works here.
I used the similar string in tMap
StringHandling.LEFT(row1.FILE_NAME),(StringHandling.LEN(row1.FILE_NAME)-4))+"_"+TalendDate.getCurrentDate()+".jpg" and it works.
I wonder since I'm able to use TalendDate I could also use other functions. Could any tell me if I've got the wrong understanding or I put it in the wrong way?
Thanks!

Accepted Solutions
Seven Stars

Re: [resolved] StringHandling function in tMap

You need to preface globalMap.get with the variable type in brackets. Also, getCurrentDate returns a Date not a String. So:
StringHandling.LEFT((String)globalMap.get("FILE_NAME"),(StringHandling.LEN((String)globalMap.get("FILE_NAME"))-4))+"_"+TalendDate.getDate("yyyyMMdd")+".jpg"

All Replies
Seven Stars

Re: [resolved] StringHandling function in tMap

You need to preface globalMap.get with the variable type in brackets. Also, getCurrentDate returns a Date not a String. So:
StringHandling.LEFT((String)globalMap.get("FILE_NAME"),(StringHandling.LEN((String)globalMap.get("FILE_NAME"))-4))+"_"+TalendDate.getDate("yyyyMMdd")+".jpg"
One Star

Re: [resolved] StringHandling function in tMap

THANKS!!!

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

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

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch