Export Function

Hello,

I am facing a strange issue regarding the export functionality.
I would like to export a specific table from my dashboard using this script. This is the standard script from Dundas samples: https://www.dundas.com/support/developer/script-library/Export/Export-Specific-Visualization-to-Excel

// Get the export service.
var exportService = this.getService(‘ExportService’);

// Get the view service.
var viewService = this.getService(‘ViewService’);

// Create the export request.
var exportRequest =
new dundas.export.ExportRequest(
{
isLegacyExport: false,
// Export Excel
providerId: dundas.constants.STANDARD_EXCEL_EXPORT_PROVIDER_ID,
viewData: this.getService(“CanvasService”).canvas.viewModel.businessObject.control
});

// Create parameter value to pass to the request.
var parameterValue = new dundas.data.CollectionStringValue();

var adapterIdsParameterId = dundas.constants.EXCEL_ADAPTERS_ID;
parameterValue.parameterId = adapterIdsParameterId;

// Set an array of adapter ids to include
// based on the value of the drop down list.

parameterValue.values = [ table3.id ];

// Push the parameter value to export request.
exportRequest.parameterValues.push(parameterValue);

var selectionParameterValue = new dundas.data.SingleNumberValue();

selectionParameterValue.parameterId = dundas.constants.EXCEL_EXPORT_SELECTION_ID;
// 3 for multiple values.
selectionParameterValue.value = 3;

exportRequest.parameterValues.push(selectionParameterValue);

// 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 =
exportService.getExportResultUrl(exportId);

  	// Force the browser to download the file.  
  	window.location.replace(exportFileUrl);
}

);

Unfortunately, this script is not working because I am receiving this error:

VM1003:54 Uncaught TypeError: exportService.getExportResultUrl is not a function
at Object.eval (eval at h (base.min.js?v=198860040000:1420), :54:21)
at l (jquery.min.js?v=198860044000:4)
at Object.fireWith [as resolveWith] (jquery.min.js?v=198860044000:4)
at k (jquery.min.js?v=198860044000:6)
at XMLHttpRequest. (jquery.min.js?v=198860044000:6)

I am using the last version of Dundas 6, 6.0.3.1012.
What should I do in this case?

Thank you!

1 Like

@costin.manea That sample script is made for v7. in v6 or earlier getExportResultUrl is a part of the webAppService.

So please change exportService.getExportResultUrl to webAppService.getExportResultUrl since you are on v6.

Also add below in the beginning of the script:
// Get the web app service.
var webAppService = this.getService(‘WebAppService’);

1 Like

Thank you @jay.gong! The export is working fine now :slight_smile:

Hi,
I am trying to use the same code for version 7 Dundas and it is not working for me. I am trying to export to excel a specific table data. I am getting Request is Invalid as an error and web response code error. @costin.manea

Hello @vinodhini.1,

Please check the script again, if you took the script from above in some cases it will not work because I’ve did some adjustments on it.
You can download the sample from here: https://www.dundas.com/support/developer/script-library/Export/Export-Specific-Visualization-to-Excel and you can check the script for V7 and earlier.

Also, you can post your script here. I can try to see what is not working :slight_smile: