Antimo
Antimo

Reputation: 480

Jasper Report IF condition in Text Field Value

Using text field value editor i add a text to the text field with a condition (note the if is constructed using the field editor of JasperSoft studio so the code IF(...) is autogenerated, i gave only the value "pippo" and "pluto")

"Some value" +IF(true,"pippo","pluto")

But it seems it don't work. I'm getting this error during calling the report from my code:

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. The method IF(boolean, String, String) is undefined for the type 

Any help will be appreciated

Upvotes: 3

Views: 21514

Answers (2)

Ruchira Nawarathna
Ruchira Nawarathna

Reputation: 1477

You need to include jasperreports-functions in your build file. e.g: for gradle

implementation 'net.sf.jasperreports:jasperreports-functions:6.12.2'

Upvotes: 0

Viki888
Viki888

Reputation: 2774

Try using ternary operator instead of IF like below

"Some value" + (value == true ? "pippo" : "pluto")

Hope this would help you out.

Upvotes: 6

Related Questions