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 2023-10-20 12:15:05

msx008
Member
Registered: 2023-09-20

Script report <= query wrapper

hello
I have a groovy script with embedded highcharts
before the sql was in the script and I will get the parameters using parameterMap
I wanted to put it in the query wrapper, but I don't know how to retrieve it or do it, I'm not a developer
I tried def query = parameterMap['_RS_QUERY'], doesn't work


to test I put it in the description (sorry) by removing the parameters, it works, otherwise I got an error message
old parameter = .... AND EXTRACT(month FROM ai.invoice_date) = $month ...

so without parameter below works
def query = parameterMap['_RS_REPORT_DESCRIPTION']
def result = sql.rows(query)

It's probably in the documentation, but I didn't understood or seen

If you can help me  to put the query in wrapper, with parameter (formated like groovy or RS) and retrieve then in the script 

regards

ps: not sure to be clear, sorry

Offline

#2 2023-10-23 10:20:08

IF_Adrian
Member
Registered: 2021-10-29

Re: Script report <= query wrapper

Hi,

Groovy replaces placeholder variables inside a String at runtime with allows you write:
def myVar = "world"
def myString = "Hello $myVar"
print(myString) --> "Hello world"
For this to work, myVar needs to be defined before myString. This might be the issue which causes your imported query not to be formatted.


If I understood your problem correctly your variables inside the query string are not replaced with parameters.
In that case you can try to replace them after importing the script:

def query = parameterMap['_RS_REPORT_DESCRIPTION']
query = query.replace('\$month', parameterMap['month']) // '$' needs to be escaped with '/'
def result = sql.rows(query)

Let me know if that works for you.

Kind regards,
Adrian

Offline

#3 2023-10-23 11:22:36

msx008
Member
Registered: 2023-09-20

Re: Script report <= query wrapper

hello
so , thanks four your help ,
I adapted it to my needs, it helped me a lot, I learned cool
my script works
by the way, can I put it in query wrapper rather than in description, if so how can I recover it?
regards

Offline

Board footer

Powered by FluxBB