parametersreportingbirt

How to handle display of optional BIRT parameters on a report?


I have an optional (multi select) list box parameter in my report. When the parameter is populated, I would like to display the filter conditions in a dynamic text box on my final report. How do I meaningfully test the parameter value to see if it is populated within the dynamic text box? I've tried combinations of

if(params["Encoding"].value == null {
""
}
else
{
params["Encoding"].value
}

but have had no luck.

I've tried testing for null and just testing .value by itself


Solution

  • Your script contains a syntax error.

    And usually the easiest way to check if a string variable x is not empty (or null or undefined) is to just use if (x). If you need a boolean value (e.g. for a visibility expression), you can use !x which returns true if x is empty or null or undefined or !!x which returns true if x is not empty. Be sure to know the difference between truthy and true in Javascript.

    If your parameter allows multiple values, then its value is a Java array. You can use the individual objects like this, e.g. to show the values in a dynamic text item:

    var p = params["Encoding"].value;
    var len = p.length;
    var out = ["p.length=" + len];
    for (var i=0; i<len; i++) {
        out.push("[" + i + "]=" + p[i]);
    }
    out.join("\n")