Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
distinguish a non-multiselectable and a multiselectable parameter
Piero
Hi
When a parameter is defined as multiselectable, the type of Object is an Array (correct?).
How can I detect the type of Object by scripting? I tryed with instanceof and typeof,
but without satisfaction. I wont to distinguish a non-multiselectable parameter from a
multiselectable.
Thanks for the help.
Find more posts tagged with
Comments
mwilliams
Can you explain a little bit more? Where are you trying to figure this out and what is your BIRT version? I'll try it out.
Piero
The Birt version is 2.6.2
For example: I will try in the expression builder to find out, if a parameter is a string or an array (when multiselectable paramater).
Thanks
mwilliams
If you put the following into a dynamic text box, it'll step through your parameters, determine if they're multi-select, and display their values accordingly. This may not be what you're trying to do, but it still shows how to check for multi-select.
Hope this helps.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
var output = "";
var paramVal = "";
var pList = reportContext.getDesignHandle().getAllParameters();
var pListSize = pList.size();
for (i=0; i<pListSize; i++){
var paramName = pList.get( i ).getFullName();
var paramType = pList.get( i ).getStringProperty("paramType");
if (paramType == "multi-value"){
paramVal = reportContext.getParameterValue( paramName ).join(", ");
}
else{
paramVal = reportContext.getParameterValue( paramName );
}
output = output + paramVal + "<br/>";
}
output;
</pre>
Piero
Michael
Thanks
that helps. And not only for checking if a parameter is multi-values ??but also to handle simpler multi-values to pass to a stored procedure.
Important is, to check first if a multi-value parameter is not null (if (reportContext.getParameterValue( paramName ) != null) ) otherwise there will be an exception.
mwilliams
You're welcome! Let us know whenever you have questions!