1

Can someone give me references where I can learn about javascript scripting in BIRT reports?

Scenario is, I have a drop down where which contains name of all car companies... Along with it, it has ALL option. When "ALL" option is selected it should display all the records of all car brands.

Currently when I select individual car names, it works fine. ALL option is not working.

Here is a code snippet.

if (params["RP_CarCompany_Name"].value == 'ALL') {
    this.queryText = this.queryText.replace('DYNAMIC_CARCOMPANY', "'" + 'BMW' + "'," + "'" + 'AUDI' + "'," + "'" + 'JEEP' + "'," + "'" + 'DATSUN' + "'");
} else {
    this.queryText = this.queryText.replace('DYNAMIC_CARCOMPANY', "'" + params["RP_CarCompany_Name"].value.join("','") + "'");
}

P.S.: DYNAMIC_CARCOMPANY is a placeholder in SQL query which is something like this

SELECT * FROM CAR_DB WHERE carcompany IN(DYNAMIC_CARCOMPANY);

Thanks for your help in advance.

Parth Raval
  • 4,097
  • 3
  • 23
  • 36
user2791560
  • 39
  • 1
  • 6
  • Try : `this.queryText = this.queryText.replace('DYNAMIC_CARCOMPANY', "'BMW', 'AUDI', 'JEEP', 'DATSUN'");` – Bob Dec 18 '17 at 14:25
  • Please, could you log your query result (credit to Jason : https://www.eclipse.org/forums/index.php/t/216762/): `importPackage( Packages.java.io ); out = new PrintWriter( new FileWriter( "c:/myquery.txt", true ) ); out.println( "My Query: " + this.queryText); out.close();` After your code. Edit your question with the result. – Bob Dec 18 '17 at 14:36
  • `this.queryText = this.queryText.replace('DYNAMIC_CARCOMPANY', "'" + ["BMW","AUDI","JEEP","DATSUN"].join("','") + "'");` This worked. – user2791560 Jan 15 '18 at 10:04

0 Answers0