Jump to content

Print When Expression with multiple conditions...


lucasleanna

Recommended Posts

iReport version 4.0.2, I have a field that should only print when multiple other fields have certain values.

$F{ONE}.equals("Yes") && $F{TWO}.equals("No") || $F{THREE}.equals("No")
 
So ONE has to be Yes and TWO or THREE have to be no, and this field will print. I've tried multiple ways attempt to get it to work using : ? if-else and making Booleans, but nothing  I've tried works. Help would be appreciated!
Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Ternary statments. The format will mimic the following syntax, however within your report you would want to omit the semicolon at the end of the statement.

     [Condition] ? [value if true] : [value if false] ;

You might be able to do what you want with one ternarystatement like ...

     $F{ONE}.equals("Yes") && ($F{TWO}.equals("No") || $F{THREE}.equals("No")) ? TRUE : FALSE

You might need to nest multiple ternarystatements like ...

     $F{ONE}.equals("Yes") ? $F{TWO}.equals("No") ? $F{TWO}.equals("No") ? TRUE : FALSE

I don't think my syntax is 100% right, especially on the nested example, but this should point you in the right direction.

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...