If Else In Expression Editor

1

Good Day All,

can anybody help me on this. I try to make an if else expression  ($F{OUT_STATUS} .equals("40") ? "Applied": "Failed" ). Main main pioint is if the Out_status data is 40 it will show Applied and other than that are failed. however when i run my report it just show Failed for all data. Note that the Out_status datatype is int and i also have try to chage it to ($F{OUT_STATUS} .equals(40) ? "Applied": "Failed" ) but the result are same.  Its my first time using jasper. Before this im a crystal developer.

 

Thank You

 

Best Regards

railey.shah's picture
Joined: Nov 18 2012 - 7:43pm
Last seen: 6 years 2 months ago

1 Answer:

5

If your field is type of Integer you should use an Integer expression instead:

$F{OUT_STATUS}.intValue() == 40?"Applied":"Failed"

 

Be sure that your field is not null, otherwise use this:

$F{OUT_STATUS} == null || $F{OUT_STATUS}.intValue() != 40?"Failed":"Applied"

 

hth + regards from Germany

C-Box

C-Box's picture
1241
Joined: Jul 19 2006 - 5:58pm
Last seen: 43 min 51 sec ago

Thank You sir, It really help me.

railey.shah - 6 years 2 months ago

Good evening!

What aboot if the field from the database is a boolean?

Thank you

rosamarozzi - 3 years 5 months ago

Boolean.TRUE.equals($F{YourBoolField}) ?"Write Static YES as its just true": "Write Static NO as its null or false"

hth
C-Box

C-Box - 3 years 5 months ago
Feedback
randomness