Go Back   Forum - BIRT Exchange > Designing BIRT Reports Forums > Eclipse BIRT Newsgroup Mirror

 
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-08-2007, 10:06 PM
Ronan
 
Posts: n/a
Default Report with parameters - script error

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


  #2 (permalink)  
Old 08-08-2007, 10:06 PM
shaik
 
Posts: n/a
Default Re: Report with parameters - script error

Hi Ronan,

The error may be in ur code which u r using,

try this following instead of which u r using, this might work


if (params["Name"] == null || params["Name"] == '')
{
if (params["CompanyName"] == null || params["CompanyName"] == '')
this.queryText = "select name, companyname, email from
ronantest..customers";
else
this.queryText = "select name, companyname, email from
ronantest..customers where companyname like
'%"+params["CompanyName"]+"%'";
}
else
{
if (params["CompanyName"] == null || params["CompanyName"] == '')
this.queryText = "select name, companyname, email from
ronantest..customers where name like '%"+params["Name"]+"%'";
else
this.queryText = "select name, companyname, email from
ronantest..customers where name like '%"+params["Name"]+"%' and
companyname like '%"+params["CompanyName"]+"%'";
}





 


Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Report with parameters - script error Ronan Eclipse BIRT Newsgroup Mirror 1 08-08-2007 10:06 PM
Binding parameters by script Thomas Eclipse BIRT Newsgroup Mirror 4 08-08-2007 04:23 PM
replace function error while passing parameters to linked report Nico Eclipse BIRT Newsgroup Mirror 0 08-08-2007 04:21 PM
How to script global parameters? Danny Rosenberg Eclipse BIRT Newsgroup Mirror 1 08-08-2007 04:18 PM
Parameters - Script Daniel Eclipse BIRT Newsgroup Mirror 1 08-08-2007 04:10 PM


All times are GMT -7. The time now is 06:25 PM.
Powered by vBulletin Copyright © 2000-2010 Jelsoft Enterprises Limited.


Content Relevant URLs by vBSEO 3.1.0