Formatting of ViewParameter labels

I have a report that uses a Date Range filter (called DateRange). The report headers Text includes the a reference to [viewParameter1], which is the SCRIPT name of the parameter named [DateRange] (why this uses the Script Name and not the Parameter name is also confusing)

What displays in my report header, which should show the currently selected range, is ">=05/01/18 & <=05/16/18"

How do I go about rendering the parameter values in a formatted manner?Image title

Hello Paul,


When you have any object in Dundas BI, you have the option to modify not only the friendly name, but the script name as well, easing the confusion when writing scripts.


Scripting inside of reports/scorecards can get a little tricky when referencing certain adapters and view parameters, hence it’s best the get the view parameter using it's ID (Vs. its name as you would on a dashboard) .


Add the script below into the dashboards properties -> Main -> Actions -> Page Ready, so each time the parameter gets changed, the report/scorecard reloads the data and it calls the script so the label can be updated.



Image title

<!------------------------------------------------>

Script:


// clearing default value

label1.labelText = " ";


// get the view parameters.

var param = this.control.getViewParameterById("8339ab0e-8b05-12bd-a39d-c97a19e4b60a");


// checking if the parameter has a set lower boundary value

if (param.parameterValue.lowerBoundaryValue != null)

{

var lowYear = param.parameterValue.lowerBoundaryValue.getUTCFullYear();

var lowMon = param.parameterValue.lowerBoundaryValue.getUTCMonth();

var lowDay = param.parameterValue.lowerBoundaryValue.getUTCDate();

label1.labelText += "From: " + lowYear + "/" + (lowMon + 1) + "/" + lowDay + " ";

}


// checking if the parameter has a set upper boundary

if (param.parameterValue.upperBoundaryValue != null)

{

var uppYear = param.parameterValue.upperBoundaryValue.getUTCFullYear();

var uppMon = param.parameterValue.upperBoundaryValue.getUTCMonth();

var uppDay = param.parameterValue.upperBoundaryValue.getUTCDate();

label1.labelText += "To: " + uppYear + "/" + (uppMon + 1) + "/" + uppDay;

}

<!------------------------------------------------>


Small modifications may be needed to the script if you have a different label name (change ‘label1’ inside script), and also paste the ID of your view parameter inside the “var param” line.


Image titleImage title


Each time the filter is changed on the scorecard, the lower and upper boundary times are pushed to the label.


Result:

Image title