I'm using Jaspersoft Studio to design my reports and then executing them from Netbeans.
I have a subreport that passes a return value to the main report and that gets added to a value in the main report to make the grand total amount.
In the main report I populate a text field with the 2 values and in the text fields Expression I add them together to make the grand total.
Variable from Main Report - $V{SubTotal2}
Variable from Sub report - $V{SubTotal1}
The problem I'm having is this...
When I write the expression as $V{SubTotal1} + $V{SubTotal2} it works succesfully when executing the report in Netbeans.
But, I need to check if Subtotal2 is not null so I need to add an IF statement in there, which looks like this -
IF($V{SubTotal1}==null,0.00,$V{SubTotal1}) + $V{SubTotal2}
When using the 'Preview' option in JasperSoft Studio it works fine and I can view the report, but when executing it through netbeans I get the following error
Error evaluating expression :
Source text : IF($V{SubTotal1}==null,0.00,$V{SubTotal1}) + $V{SubTotal2}
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : IF($V{SubTotal1}==null,0.00,$V{SubTotal1}) + $V{SubTotal2}
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:244)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:1016)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:504)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:488)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:259)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:456)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2057)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupFooter(JRVerticalFiller.java:943)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillGroupFooters(JRVerticalFiller.java:809)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportEnd(JRVerticalFiller.java:317)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:158)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:939)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:852)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:87)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:276)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:745)
at nmtbatchservice.jasperreporting.JasperReportGenerator.generateReport(JasperReportGenerator.java:53)
at nmtwebservice.reporting.BillIssuerReport.generateReport(BillIssuerReport.java:178)
at nmtbatchservice.NMTBatchService2.main(NMTBatchService2.java:155)
Caused by: net.sf.jasperreports.engine.JRRuntimeException: Function IF not found
at net.sf.jasperreports.compilers.GroovyEvaluator.functionCall(GroovyEvaluator.java:73)
Any ideas? As I said - it works through Jasper Studio but not when I use netbeans.