Hi,
I am a newbie to BIRT & attempting to get my first report with parameters
working. I wish to have the user prompted with 2 input fields which are
both optional. Leaving them blank means the query should not include
within the WHERE clause. Alternatively the user may choose to enter text
for both or one & not the other etc.
To facilitate this I am trying to dynamically change the query within the
dataset's beforeOpen() script, based on input parameter values. I used the
example at:
http://wiki.eclipse.org/index.php/Nu...Data_Set_(BIRT)
Here are my details?
- Data Source:
MS SQL Server 2000 db
- Table Name: Customers
- Query (executed if no report parameter values specified):
select name, companyname, email from ronantest..customers
- DataSet
No dataset parameters specified as the query is dynamically altered using
javascript within beforeOpen() method of dataset.
EG.
if (params["Name"].value && params["CompanyName"].value){
this.queryText = "select name, companyname, email from
ronantest..customers where name like '%" + params["Name"] + "%' and
companyname like '%" + params["CompanyName"] + "%'";
} else if (params["Name"].value && params["CompanyName"].value = ''){
this.queryText = "select name, companyname, email from
ronantest..customers where name like '%" + params["Name"] + "%'";
} else if (params["CompanyName"].value && params["Name"].value = ''){
this.queryText = "select name, companyname, email from
ronantest..customers where companyname like '%" + params["CompanyName"] +
"%'";
}
Report parameters which will be prompted to the user are as follows:
- Name
- CompanyName
When I go to preview the report I get the following error:
<error-log>
The following items have errors:
Table table1:
+ There are errors evaluating script "if (params["Name"].value &&
params["CompanyName"].value){
this.queryText = "select name, companyname, email from
ronantest..customers where name like '%" + params["Name"] + "%' and
companyname like '%" + params["CompanyName"] + "%'";
} else if (params["Name"].value && params["CompanyName"].value = ''){
this.queryText = "select name, companyname, email from
ronantest..customers where name like '%" + params["Name"] + "%'";
} else if (params["CompanyName"].value && params["Name"].value = ''){
this.queryText = "select name, companyname, email from
ronantest..customers where companyname like '%" + params["CompanyName"] +
"%'";
}".
</error-log>
Any help would be greatly appreciated.
Thanks,
Ronan