You are not logged in.
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:
We will keep you informed in the pinned thread.
Kind regards,
Your ReportServer Team
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:
Wir halten euch im angepinnten Beitrag auf dem Laufenden!
Mit vielen Grüßen
Euer ReportServer Team
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
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
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
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
Hi Johann,
thanks for letting us know about your solution.
Regards,
Eduardo
Offline