I am trying to pass a start and an end date range to a report from within a Dashboard. The script that I am using is provided below. I know how to get the values from dropdowns and pass them to the report, but am having a difficult time passing the “var end” and “var start” date which is are date values to the “var queryString”. I am passing the dropdowns using the currentValues, and what is the best approach to pass the start and end date values to a subReport using “keyValuePair”, can it be injected within?
// Get the export service.
var exportService = this.getService(‘ExportService’);
// Get the view service.
var viewService = this.getService(‘ViewService’);
var webAppService = this.getService(‘WebAppService’);
// Set the report id.
var reportId = ‘fdcea8b2-2c14-4d58-a2f5-1e49c8f76da0’;
var end = parameterDateTime1.control.endValue;
var start = parameterDateTime1.control.startValue;
var currentValues = “”;
var viewParameterValue = this.parentView.control.viewParameters[1].parameterValue.values[0].uniqueName;
if (viewParameterValue.token) { // I’m treating any token as All for this example
currentValues = "$*$"; // All token Shorthand Name
} else { // Since it’s a Collection Member Value the members must be split with a pipe |
$E(this.parentView.control.viewParameters[1].parameterValue.values).forEach(function(v) {
currentValues = currentValues + encodeURIComponent(v.uniqueName) + "|";
});
}
var queryString = [new dundas.KeyValuePair(dundas.constants.EDIT_QUERY_STRING_KEY, “false”),
new dundas.KeyValuePair(dundas.constants.VIEW_OPTIONS_QUERY_STRING_KEY, dundas.ViewOptions.VIEW_ONLY),
new dundas.KeyValuePair(dundas.constants.IS_EXPORT_QUERY_STRING_KEY, "true"),
new dundas.KeyValuePair("$vwDivision", currentValues)];
var contextual = dundas.Utility.getContextualPageUrl(
dundas.Pages.REPORT,
{
id: reportId,
queryString: queryString
}
);
var shortLinkService = window.dundas.context.getService(“ShortLinkService”);
// Get the shortlink.
var shortLinkPromise = shortLinkService.getShortLink(contextual);
shortLinkPromise.done(
function(shortLink)
{
var fullLinkAddress = dundas.Utility.getContextualPageUrl(dundas.Pages.LINK, {
"queryString": [new dundas.KeyValuePair(dundas.constants.SHORT_LINK_QUERY_STRING_KEY, shortLink)]
});
// Create the export request.
var exportRequest =
new dundas.export.ExportRequest(
{
// PDF provider id.
// //providerId: dundas.constants.STANDARD_PDF_EXPORT_PROVIDER_ID,
providerId: dundas.constants.STANDARD_PDF_EXPORT_PROVIDER_ID,
viewId: reportId,
});
exportRequest.viewUrl = fullLinkAddress;
// Get the perform export promise.
var exportPromise =
exportService.performExport(exportRequest);
// Setup a loading dialog.
viewService.showLoadingRestCall(exportPromise);
exportPromise.done(
function(exportId)
{
// Get the Url for the export file.
var exportFileUrl =
webAppService.getExportResultUrl(exportId);
// Force the browser to download the file.
window.location.replace(exportFileUrl);
}
);
}
);