Pass Groovy element to SQL

Hello,

I have the following Groovy script in Report band “head”, which have child bands:

def periodData = params[“Inquiry”]

return [[“id”: periodData.period.id]]

How can I pass the returned “id” from the Groovy script, to the child Report band?

Hi Dimitar,
You don’t need to pass it explicitly, just call it from a child band as ${head.id}. Let me give you an example:

  1. A parent band (named “parent”) has the following Groovy script:
import com.haulmont.cuba.core.global.AppBeans;
import com.haulmont.cuba.core.global.UserSessionSource;

String login = AppBeans.get(UserSessionSource.class)
                     .getUserSession().getUser().getLogin();
                     
return &#91;&#91;"<i>generated_by</i>":login, 
    "generated_when":new Date()&#93;&#93;
  1. A child band (named “child”) has the following JPQL:
select 
    u.email as user_email
from sec$User u 
where u.login = ${<b>parent</b>.<i>generated_by</i>}

Regards,
Aleksey