Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Last revisionBoth sides next revision
72:custom_reports_accessing_data_accessing_parameters [2019/02/07 14:07] – created ext-bkkr72:custom_reports_accessing_data_accessing_parameters [2019/03/06 19:40] ext-bkkr
Line 1: Line 1:
 ====== Accessing Report Parameter through a Data Set Script ====== ====== Accessing Report Parameter through a Data Set Script ======
 +
 +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. //
 +<code>
 +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;
 +</code>
 +
 +5. Copy the data Set script from the example into your Data Set.
 +
 +<code>
 +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);
 +</code>
 +
 +\\