Select individual entities by index in dataset queries

Thanks for the reply!

I have a follow-up question:

If I have a report that takes a “List of entities” parameter, how can I select individual entities by index in dataset queries? I know for single entity type fields I just need to use ${parameterAlias}.
If this is possible, could you post a query example with checks for dealing with index out of bound?

Thank you!

Hi, @kuo.hong!

It is not possible to access individual entity from “List of entities” parameter by alias for SQL and JPQL queries, but it is posible to use query preprocessing where you can access entities using Groovy.
For example, we have JPQL dataset and parameter with alias listOfEntitiesParam and want to pass list of id to use it for IN clausure:

select
e.someField as "someField"
from exampe_TestEntity e
where e.id in (<% out << listOfEntitiesParam.collect { "'$it.id'" }.join(",") %>)

Or we need to do some calculations:

...
where e.number =
<% def sum = 0
listOfEntitiesParam.each { entity -> sum += entity.number}
out << sum %>

and e.t.c.

Regards,
Sergey