0

Having some problems trying to get multi value list box values to be accepted in the BIRT engine API.

The error I'm seeing is "The type of parameter "EmployeeType" is expected as "Object[]", not "java.lang.String".

I've tried multiple variations in the beforeOpen clause to get it to parse these correctly but it always returns the same error when running the report.

The section of the query where the values need to go looks like where pebempl_stgr_code in (?)

And it should be just a list of comma separated values, but its not working. All the searching I've done comes up with problems from 2011 and prior and I'm out of ideas.

Edit:

1st beforeOpen script tried was this

this.queryText=this.queryText.replace("placeHolder","where pebempl_stgr_code in ('" + params["employeeType"].value.join("','") + "')");

Worked in the built in web viewer, but will not work with the Engine API

Then tried a modified version of this:

var parmcount = params["parmorders"].value.length
var whereclause = "";
if( parmcount > 0 ){
    whereclause = " where customernumber in ( ";
}
for( i=0; i < parmcount; i++ ){
    if( i == 0 ){
        whereclause = whereclause + params["parmorders"].value[i];
    }else{
        whereclause = whereclause + " , " + params["parmorders"].value[i];  
    }
}
if( parmcount > 0 ){
    this.queryText = this.queryText + whereclause + " ) ";
}

And it works the same way, runs fine in the web viewer, but will not run in the Engine API.

idonaldson
  • 465
  • 1
  • 14
  • 33

1 Answers1

0

We cannot do this with a regular SQL parameter '?'. Please see a workaround here, you have to build this 'in' clause in beforeOpen script of the dataset

EDIT: Furthermore, as mentionned by the exception you get, you have to set an array of object (for example an array of string or an array of integer, depending on the datatype of the report parameter) not a String representing a comma separated list of values. That means if the java application gets a such String, it is necessary to split it into an array before setting the parameter to engine tasks.

Community
  • 1
  • 1
Dominique
  • 4,272
  • 1
  • 16
  • 21
  • I've tried that, and no luck. I'll edit the post with the beforeOpen scripts I've tried. – idonaldson Jul 07 '14 at 21:35
  • No luck again. I walked through my code to make sure it's returning as an array, and it looks like if there are more than one item selected from the view, it comes back as `[Ljava.lang.String;` but still throws the error message. – idonaldson Jul 07 '14 at 22:08