Print when expression ireport more than one condition

ireportjasper-reports

Can i put more than one condition at print when expression? and can pls tell the syntax.
example,

(cb.flag = 'A' or cb.flag = 'B' or cb.flag = 'C') and cb.type <> 'O'

  • i need to use OR condition together with AND.

Thanks.

Best Answer

Syntax is (condition) ? value1 : value2 In place of value1 and value2 you may have other constraints.

Here is an example that uses a Java constraint:

(($F{ca} > 8) && ($F{ca} < 12) ? "near 10" : (($F{name}.charAt(0) == 'A') ? "A": "Not A" ))

These are Java expressions, so you have to be careful with == and =.

Now the print part...

So far you have defined a Variable variable1, which is a String variable (could be anything else) and behaves accordingly to the constraint you have defined.

You just need to drag it from your the Variables group of your Report Inspector to the zone (most likely the Detail zone) of your report. Then it becomes $V{variable1} and prints in your zone whatever the constrain dictates. That's it.

enter image description here

Related Topic