Search code examples
javascriptmysqlbirtproperty-binding

Javascript in either property binding or Query in Birt


Can I include javascript in the property binding Query Text field of a BIRT report Data Set? The reason why I want to do this is to select a query depending on a report parameter passed by the user.


Solution

  • Yes, for instance you can do this in this field:

    var param=params["myParameter"].value;
    if (param==1){
      "select code,label from tableA";
    }else{
      "select code,label from tableB";
    }
    

    However this makes reports more difficult to maintain. Most of the time it is a better practice to modify an existing queryText from "beforeOpen" method of the dataset, by replacing keywords such explained in this topic