Return value of variable is null inside report


in Jaspersoft I create a variable of type string that do a simple operation inside a tenary code.

($P{Param1}.length() == 0) ? $V{var_x} : $V{var_x}.length() == 6 ? $V{var_x} + $P{Param2}.toString() : "Error"

In this case var_x represents a string like "01.01.". If true var_x should be concatinated with an int value like 1971.

But the return value of the variable is always null. Because I'am new to JasperReports and Jaspersoft I'am not sure if this is a setting inside the software or if the ternary operator is not valid in Jaspersoft.

Did someone have a hint for me?

Kind regards

mpolo91's picture
Joined: Nov 30 2022 - 8:23am
Last seen: 5 months 3 days ago

1 Answer:

A couple of things to check:

- Make sure the Variable has an "Initial Value Expression" set, or that the Variable :var_x" is populated before the above expression is executed.

- Check the "Evaluation Time" of when the variable is used.

Confirm the other properties around the Variable.

sanderse's picture
Joined: Jul 31 2017 - 3:51pm
Last seen: 1 day 12 hours ago