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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Null pointer exception - tMap

Hi everyone,
I am facing this error (c.f screenshot) for a while now. Usually Google is my friend, but not today.
Thank you for your advice,
0683p000009MCGM.png 0683p000009MCGR.png 0683p000009MCBE.png
EDIT :
I think the error comes from the absence of a null test. Therefore I tried this 3 kind of test but none works.

(String)row7.selling_price.equals(null))?0:row7.selling_price

(row7.selling_price.toString().equals(null))?0:row7.selling_price

(row7.selling_price == null)?0:row7.selling_price
Labels (2)
26 Replies
Anonymous
Not applicable
Author

Hi,
There is null pointer exception in your tMap component.
You need to handle the null value. Is your row7.selling_priceP" Integer" data type? If so, please parse Int to String firstly and then
row7.selling_priceP)==null|| row7.selling_priceP .isEmpty())? value if it is null:do your further processing
Best regards
Sabrina
Anonymous
Not applicable
Author

Hi xdshi,
What do you mean by " parse Int to String"
How can I do that and where ?
Thx,
Anonymous
Not applicable
Author

Hi,
Please take a look at the attached screenshots.
Or you can use String.valueof in your expression, such as, String.valueOf(row1.newColumn)==null||(String.valueOf(row1.newColumn).isEmpty()
Best regards
Sabrina
0683p000009MC9X.png 0683p000009MBwb.png
Anonymous
Not applicable
Author

The following code doesn't work (cf. screenshot) 😕
(String.valueOf(row8.payment_date)==null||String.valueOf(row8.payment_date).isEmpty())?false:true
I mean I get a "true" while I should get a "false" since row8.payment_date = null
0683p000009MCGW.png
Anonymous
Not applicable
Author

Hi,
The ternary operation in tMap should be:
Condition?value if true: value if false
Best regards
Sabrina
Anonymous
Not applicable
Author


My code is respecting the format.

My destination_field is a boolean.

(String.valueOf(row8.payment_date)==null||String.valueOf(row8.payment_date).isEmpty())?false:true     

IF row8.payment_date is null or empty
   destination_field = false
ELSE
   destination_field = true



I face the same issue with a destination_field as a String and this code.


(String.valueOf(row8.payment_date)==null||String.valueOf(row8.payment_date).isEmpty())  ? "NULL OR EMPTY" : "NOT NULL AND NOT EMPTY"




I also tried to use the following code but it doesn't work neither.


(Relational.ISNULL(row8.payment_date)?false:true
Anonymous
Not applicable
Author

Hi,
What's the actual result you are facing? Is it still null pointer exception in tMap? Have you tried to check "Code" tab to see if there is any compile error?
Best regards
Sabrina
Anonymous
Not applicable
Author

I am still looking for the right code to use in order to check if my Date field is null or not.
As you can see on the screenshot below this code doesn't give me the right output value.
Since the value of payment_date=null, that means that the condition is true then I should get the value right after the '?' which is in my case false.
We can clearly see on the screenshot I get a true 0683p000009MPcz.png
(String.valueOf(row8.payment_date)==null||String.valueOf(row8.payment_date).isEmpty())?false:true

Thx a lot for helping me on that issue 0683p000009MACn.png
0683p000009MC3f.png
Anonymous
Not applicable
Author

Why are you using "String.valueOf"? It is that which is causing you problems. To check to see if an object is null, all you need to do is use "==null". You also won't get an empty date if the object is a Date. So your check should be similar to below I believe....
row8.payment_date==null ? false:true