Parameters not being passed to iReport

Im currently using Servoy 7 (Latest Build) along with iReports Version 5 but am having problems getting a simple parameter to be passed from my code to the Report

The following is the code for a simple button to view the report in my Servoy Solution

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"ED06AA59-4A82-4898-B0C0-B17321453011"}
 */
 function btnPrintRPT(event) {

//		var params = new java.util.HashMap()
//		params.put("operator_code", '"SAMJ"')
//		var serverName = databaseManager.getServerNames();		
		var params = new Object();
		params.operator_code = forms.ReportTest.user_code;
//		params.parameter2 = 2;
		
		plugins.jasperPluginRMI.runReport("acss", "report4.jrxml", null, "print", params);
	}

Below is the SQL query for the report in iReport the operator_code parameter was set up accordingly as a Java String Parameter

SELECT
     operators."operator_id" AS operators_operator_id,
     operators."creation_date" AS operators_creation_date,
     operators."name" AS operators_name,
     operators."user_code" AS operators_user_code
FROM
     "public"."operators" operators
WHERE
operators."user_code" = $P{operator_code}

I have tried changing various things to try and get it working such as defining the params variable as an object or a new java Hash Map all to no avail. Any help or obvious errors I have over looked would be greatly appreciated

I see a couple of issues you need to be aware of:

  1. iReport version 5 may not work with the version of the JasperReports plugin shipped with Servoy v7. Check on the libraries shipped with Servoy v7.(I assume you are using that plugin?)

  2. In your where clause you might try adding the “!” after the $P:

operators."user_code" = $P!{operator_code}

Thomas Parry:
2. In your where clause you might try adding the “!” after the $P:

operators."user_code" = $P!{operator_code}

As far as I know you only need to do this when you are inserting SQL code into the statement.
Lets say you provide filter information from servoy to fill the following sql query in your iReport:

SELECT fields FROM table WHERE $P!{CONDITIONS}

you can provide the filters as this:

params.put('CONDITIONS', 'field_1=21 AND field_2="abc"'

I think the problem is indeed in the iReport version that you are using. Check the servoy forge Wiki for information about versions:

I use iReport 3.7 with plugin 3.2.0 with great success.

Couple of questions.

  1. You don’t mention if you are getting any error message.
  2. Does the report run correctly directly out of iReport? I have found it easier to debug run reports using data connection in iReport rather than passing a found set.

Thanks for the quick responses, much appreciated

To answer your questions I was indeed receiving an error but there was no details with it other than wrapped java exception. Also the report was running fine out of iReports.

I have since gone back and looked at the versions and changed my Jasper Plugin version from 3.3.1 to 4.0 and the code I listed in the original post now works fine. I am assuming it was just a compatibility issue that I had over looked.