Multiple Parameters

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);

    }

);

}

);

does this tread help you out any?

https://dundas.influitive.com/forum/t/how-to-get-from-and-to-date-from-range-date-filter-to-use-in-a-formula-measure/1262

If your goal is to parameter-ize the current view’s view parameters to save them, then you don’t need to use the query string short hand necessarily. You can instead do something like this:

// Querystring
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")];

var currentView = this.parentView.control;

// Update the view parameter values on the overrides.
currentView.overrides.updateDefaultViewParameterValues(currentView);

// Try to get a KVP.
var kvp = currentView.overrides.toKeyValuePair();
if (kvp) {
    queryString.push(kvp);
}

// Clear the overrides back out.
currentView.overrides.clearDefaultViewParameterValues();

This will only work if the currentView is the same as reportId. If it’s not the same one, then before calling toKeyValuePair() you would want to adjust defaultViewParameterValues property on overrides class (which is a dundas.view.controls.ViewOverrides class) and modify the viewParameterId or set it to null and instead set viewParameterName to “vwDivision” (as per your sample).

When short links can be used, it’s always preferable to use the actual class types and serialize them instead of the queryString short-hand which is more used for embed / browser URL manipulation.