Announcement

Migration of this forum

Dear users of this forum,

we are pleased to inform you that we will be updating the software behind this forum in the near future.

Existing posts, users and categories will remain untouched.

Important:

  • Each user will need to reset their password.
  • Please select "I forgot my password".
  • Enter the email address you used to register in this forum.
  • You will receive an email with a link to set a new password.
  • Please choose a new (secure) password and confirm the process.

We will keep you informed in the pinned thread.

Kind regards,
Your ReportServer Team


Migration des Forums

Liebe Nutzer dieses Forums,

wir freuen uns, euch mitteilen zu können, dass wir in naher Zukunft die Software hinter diesem Forum aktualisieren werden.

Existierende Beiträge, Nutzer und Kategorien bleiben weiterhin bestehen!

Wichtig:

  • Jeder Nutzer muss sein Passwort neu vergeben.
  • Wählt dazu einfach "Ich habe mein Passwort vergessen".
  • Gebt die E-Mail-Adresse ein, mit der ihr registriert seid.
  • Ihr erhaltet eine E-Mail mit einem Link zur Passwortvergabe.
  • Bitte wählt ein neues (sicheres) Passwort und bestätigt den Vorgang.

Wir halten euch im angepinnten Beitrag auf dem Laufenden!

Mit vielen Grüßen
Euer ReportServer Team

#1 2022-06-01 04:06:39

Johann
Member
Registered: 2022-05-30

How to access ReportServer global constants from Groovy script

I understand how to define global constants in ReportServer and that they can be used in reports such as Dynamic Lists, BIRT, Jasper, etc.

However, I've not found a way to use them in Groovy scripts. Could anyone share how this could be achieved? Thank you!

Reference: https://reportserver.net/en/guides/admi … Constants/

Offline

#2 2022-06-01 09:20:50

IF_Eduardo
Administrator
Registered: 2016-11-01
Website

Re: How to access ReportServer global constants from Groovy script

Hi Johann,

you can use services for this. Here are the relevant documents:

The javadocs can be found here: https://reportserver.net/api/current/javadoc/index.html
List of entities: https://reportserver.net/api/current/entities.html
List of hooks: https://reportserver.net/api/current/hooks.html
List of services: https://reportserver.net/api/current/services.html

So in your case, you can see in the services list: GlobalConstantsService
which has     getConstantFor(java.lang.String name)  for reading the value of a given global constant.

For using the service, you can just type:

def globalConstantsService = GLOBALS.getInstance(GlobalConstantsService)

Regards,
Eduardo

Offline

#3 2022-06-01 10:32:40

Johann
Member
Registered: 2022-05-30

Re: How to access ReportServer global constants from Groovy script

Got it, thanks so much Eduardo!

On a similar note, how about if we were to import groovy methods (from other files) instead of importing constants? Would using GLOBALS still be the right solution?

Offline

#4 2022-06-07 09:06:35

Johann
Member
Registered: 2022-05-30

Re: How to access ReportServer global constants from Groovy script

I have found a solution for importing methods, which I came across while trying out the demo. Essentially, we can create a Groovy helper file containing the relevant methods and execute it in the Groovy script using:

GLOBALS.exec(‘path/to/lib.groovy’)

Offline

#5 2022-06-07 09:10:53

IF_Eduardo
Administrator
Registered: 2016-11-01
Website

Re: How to access ReportServer global constants from Groovy script

Hi Johann,

thanks for letting us know about your solution.

Regards,
Eduardo

Offline

Board footer

Powered by FluxBB