Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Streamlining user types in Qlik Cloud capacity-based subscriptions: Read the Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Expressions not defined

I am trying to use some of the build-in functions in the expression builder. Several functions give an error saying that the method is not defined:
An example of this is the LEFT function:
The method LEFT(String, int) is undefined for the type TalendJavaSourceViewer31

In the Expression Builder (in a tMap), I have:
LEFT(row1.FirstName,50)
Labels (3)
5 Replies
Anonymous
Not applicable
Author

You need to refer to the function as
StringHandling.LEFT(row1.FirstName, 50)

LEFT is a static method defined in the StringHandling class.
Regards,
Abhi
Anonymous
Not applicable
Author

Ok. Tried that, and still getting an error. The syntax is now correct in the tMap expression, but when I run the full job I get:
Exception in component tMap_1
java.lang.NullPointerException
at routines.StringHandling.LEFT(StringHandling.java:209)


The code in my tMap expression is:
StringHandling.LEFT(row1.FirstName,50)
Anonymous
Not applicable
Author

I think you are getting "null" value for row1.FirstName. While making a call to StringHandling.LEFT, we need to ensure that row1.FirstName is not null. The following expression will evalute to null if row1.FirstName is null, else it will return the first 50 characters of row1.FirstName (or row1.FirstName itself, if length of row1.FirstName is less than 50).
row1.FirstName != null ? StringHandling.LEFT(row1.FirstName, 50) :
null
Anonymous
Not applicable
Author

That was the answer. Thanks!
alevy
Specialist
Specialist

All StringHandling methods will be null friendly in v4.0.4 and v4.1.2 (see https://community.talend.com/t5/Archive/resolved-tMysqlInput-1-NB-LINE/td-p/176131).