You are not logged in.
Pages: 1
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
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
hello
so , thanks four your help ,
I adapted it to my needs, it helped me a lot, I learned
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
Pages: 1