metadata values in script reports

Hi,

How to get values of report’s metadata in script reports?

Cheers,
Karolina

Hi Karolina,

in a script report you get access to the report object via the variable

report

As the metadata is not stored on the report variant (which is automatically created behind scenes, even if you execute a base report)
you need to access the parent to get to the metadata. That is

report.getParent()

To get a specific metadata field you can then use the method getReportMetadataByName(“key”).

The following is an example that just outputs all available metadata

return "<ul>" + report.getParent().getReportMetadata().collect { 
  "<li>" + it.getName() + ": " + it.getValue() + "</li>"
}.join() + "</ul>";

getReportMetadata returns a collection of net.datenwerke.rs.core.service.reportmanager.entities.reports.ReportMetadata objects.

Cheers
Arno

Hi Arno,

Thanks a lot for this explanation.

Are there other variables like that (i.e. that its not necessary to declare them) that are available in script reports?

Karolina

Hi,

yes, there are a few

  • outputFormat: The requested output format
  • parameterSet: The parameters (this is an object containing all the parameters as they are represented within ReportServer)
  • parameterMap: A map of the parameters. More convenient to use. Key should point to the actual parameter
  • connection: the database connection if one is configured
  • report: the report object
  • user: the current user

I think those are the important ones.

Arno

Thanks!