If a column to be printed on a Jasper report represents multiple fields in Servoy,
$F{std_name_last} + ", " + $F{std_name_first} + " " + $F{std_name_middle}
…is it possible to have an IF() statement to determine whether one or more of these fields are empty, so that one doesn’t end up with
Miller, Jeffrey null
…?
Thank you,
Don
This is the syntax:
$F{std_name_last} + ", " + $F{std_name_first}+($F{std_name_middle} == null ? ‘’ : ’ '+ $F{std_name_middle})
Gianluca
Ciao Gianluca,
When I try an expression of the form,
($F{std_dob} == null? " " : ($F{std_dob}.getMonth() + 1) + "." + $F{std_dob}.getDate() + "." + $F{std_dob}.getYear())
It prints, but I get strange years (e.g., 102 for 2002, 108 for 2008). If I try the following,
($F{std_dob} == null? " " : ($F{std_dob}.getMonth() + 1) + "." + $F{std_dob}.getDate() + "." + $F{std_dob}.getFullYear())
I get an error in the Servoy console, and no report. I also get an error when I try,
($F{std_dob} == null? " " : ($F{std_dob}.getMonth() + 1) + "." + $F{std_dob}.getDate() + "." + $F{std_dob}.getYear().substr(1,2))
Do you know what the problem might be?
Molte grazie,
Don
djlapin:
Ciao Gianluca,
When I try an expression of the form,
($F{std_dob} == null? " " : ($F{std_dob}.getMonth() + 1) + "." + $F{std_dob}.getDate() + "." + $F{std_dob}.getYear())
It prints, but I get strange years (e.g., 102 for 2002, 108 for 2008). If I try the following,
($F{std_dob} == null? " " : ($F{std_dob}.getMonth() + 1) + "." + $F{std_dob}.getDate() + "." + $F{std_dob}.getFullYear())
I get an error in the Servoy console, and no report. I also get an error when I try,
($F{std_dob} == null? " " : ($F{std_dob}.getMonth() + 1) + "." + $F{std_dob}.getDate() + "." + $F{std_dob}.getYear().substr(1,2))
Do you know what the problem might be?
Molte grazie,
Don
Hi Don,
Why do you want to use an IF statement to print a date without null? You can use a PATTERN property to format a date (e.g. “dd.MM.yyyy”) and check “Blank when null” option to suppress null: you can use “Blank when null” for all the fields.
Gianluca
Ciao Gianluca,
Unfortunately, that didn’t work when I tried it (see attached). I attempted a number of permutations of the formatting strings, but none of them made a difference in the output. Am I doing something incorrectly?
Thank you,
Don
tparry
March 3, 2012, 12:08pm
7
The pattern ‘dd/MM/yyyy’ will only work if the type is Date not for String, which is I assume what you still have as the result of the function.
The text expression is now a simple field of type Date (shown in attached picture). Am I missing something?
Thank you,
Don