setQuery with wrong param value

Hi,
I tried to pass a param from a edit screen to a browse screen which has a sql to fetch the data by the param. But It shows an error when click lookup action. Thank you.

IllegalArgumentException: You have attempted to set a value of type class java.lang.String for parameter param_aaaa with expected type of class com.company.mastert.entity.UDCTYPE from query string  select e from mastert$UDC e where e.udctype=:param_aaaa.
@Override
public void init(Map<String, Object> params) {
    super.init(params);
    PickerField.LookupAction action = (PickerField.LookupAction) testtypeField.getAction(PickerField.LookupAction.NAME);
    action.setLookupScreenParams(ParamsMap.of("aaaa", "TESTTYPE"));
}
@Override
public void init(Map<String, Object> params) {
    super.init(params);
    if (params.containsKey("aaaa")) {
        uDCsDs.setQuery(
                " select e from mastert$UDC e where e.udctype=:param$aaaa");
        uDCsDs.refresh();
    }
}

Hello @thomaslei

It seems that you are trying to pass enum value as parameter, am I right?

In this case you should pass a value that can be stored in the udctype field. Each enum has an id for its values, so you should pass an id of corresponding enum value as a parameter.

Regards,
Daniil.

Hi,
Thank you. It works now. I changed from :param$ to :custom$

        if (params.containsKey("testtype")) {
            uDCsDs.setQuery(
                    " select e from mastert$UDC e where e.udctype.typename = :custom$typename");
            String query = uDCsDs.getQuery();
            uDCsDs.refresh(ParamsMap.of("typename", params.get("testtype").toString()));
        }