This example shows how to pass a report paramter to a Stages Data Set collection script.
1. Create a Report with a Stages Data Source and a Data Set
2. Create the following Data Set result columns:
Name | Type |
---|---|
debug | String |
3. Define a two report parameter.
4. Copy the following Data Set beforeOpen script.
Notice: The following script retrieves the parameter values and replaces the paramter place holders /*Parameter_Multiselect*/ and /*Paramter*/ with the report parameter value just before the data set is executed.
parameters = reportContext.getParameterValue("Parameter_Multiselect"); var FilterArray = ""; if (parameters != null) { if ( typeof parameters.length == 'function') { FilterArray = "\"" + parameters + "\""; } else { for( i=0; i <parameters.length; i++ ){ if( i == 0 ){ FilterArray = FilterArray + "\""+parameters[i]+"\""; } else{ FilterArray = FilterArray + ",\""+parameters[i]+"\""; } } } } tmp = this.queryText.replace("/*Parameter_Multiselect*/",FilterArray); this.queryText = tmp; tmp = this.queryText.replace("/ *Parameter*/",reportContext.getParameterValue("Parameter")); this.queryText = tmp;
5. Copy the data Set script from the example into your Data Set.
function debug(str) { dataset.setColumnValue("debug",str); dataset.storeResultRow(); } Paramater_Multiselect = new Array(/*Parameter_Multiselect*/); Parameter = new String("/*Parameter*/"); for each (value in Paramater_Multiselect) { debug(value); } debug(Parameter);