Jasper Reports With Calculations

Hello all,

I’m struggling trying to create a simple report using a foundset calculation as a field in the report. I can access other foundset fields, including related values, but no success with calculations. Jasper tells me it can’t find the field.

Is it possible someone send an example of a xml jasper report with a calculated field from a foundset.

Thanks in advance.

What version of Servoy and which version of the Jasper plugin are you using?

Also, out of curiosity why did you choose to use Jasper + Native Servoy object for your reporting choice?

Hello,

Servoy version 5.1.0 - build 956.
Jasper plugin version 3.0.1a1.

I’m using Jasper + Native Servoy Object only in one specific scenario where we want to generate a dynamic parameterized report from Servoy. Thus, the report is generated at runtime, we build the XML ourselves. I need to pass a foundset because it already includes the filtered records I want to display.

I’ve tried to use calculations as a normal field, but it doesn’t work. I get the following error:

java.lang.Exception: Error evaluating expression :
Source text : $F{iscommenced_jobheader}
Error evaluating expression :
Source text : $F{iscommenced_jobheader}
Wrapped java.lang.Exception: Error evaluating expression :
Source text : $F{iscommenced_jobheader} (C:\Projects\workspace_tsmseven\reports\globals.js#64)
at C:\Projects\workspace_tsmseven\reports\globals.js:64 (rep_runGridReport)

Is there any example of using calculations in a report?

Thanks.

I found the problem myself. My reports were missing the attribute - language=“groovy” - in the jasperReport tag. For instance this is the way it should be:

<jasperReport xmlns='http://jasperreports.sourceforge.net/jasperreports' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd' name='test_report_01' language='groovy'>

If you don’t set the language, it’s not possible to use the calculations.

Cheers,