Setting a text field to display conditionally based on age.
Submitted by Ascot_Vet_Surgery on Fri, 29/07/2022 - 14:11
I have a text field in a jasperreport that I want to display if the animal is over 7.
I created a variable (boolean) that was set to the expression
YEAR(TODAY())-YEAR($F{patient.entity.datefBirth})>7
I also tried
YEARS($F{patient.entity.datefBirth}, Today())>7
both still return false even when the patient is 15 on file.
Re: Setting a text field to display conditionally based on age.
I additionally noted that if I tried to rpelace the date:now() function with $F{startTime} the function returned a jxpath error which is strange considering the getReminders function takes a java.util.Date as the param which is what that variable is
Re: Setting a text field to display conditionally based on age.
You have a typo in your field name. It should be:
The easiest way to diagnose these problems is to create a field for each part of the expression you are having trouble with i.e. create a field for each of:
$F{patient.entity.datefBirth}
YEAR(TODAY())
YEAR($F{patient.entity.datefBirth})
The first will display null indicating there is a problem with that field
Re: Setting a text field to display conditionally based on age.
Any ideas on the other issue with the reminder report data source and filtering it based on startTime as opposed to the current date
Re: Setting a text field to display conditionally based on age.
Any ideas on the other issue with the reminder report data source and filtering it based on startTime as opposed to the current date
Re: Setting a text field to display conditionally based on age.
Try:
or:
The $F. and $P. prefixes allows JasperReport fields and parameters to be exposed to jxpath functions.