Run filter on screen open

Hi,

I have a ‘method’ attribute in my Projects entity which came from Method entity. And when the user opens Projects browser screen I want it to automatic filter for “the xy method”.
I have read Query Filter documentation, so I should insert something like that into my screen descriptor:


<query> 
 <!&#91;CDATA&#91;select e from myproject$Projects e&#93;&#93;> 
 <filter>                <and>                    <c>e.method.id = :param$projectsMethod</c>                </and> 
 </filter> 
 </query>

But I d not know where to give :param$projectsMethod’s value. I tried e.method. = “the xy method%”, but do not works.

Could anyone help me how to resolve this problem?

Thanks,
Carol

Hi Carol,

If you want to filter by a Method attribute, say “name”, use this:


<c>e.method.name = "the xy method"</c>

or


<c>e.method.name like "the xy method%"</c>

Hi,

Thanks for your help.

So I inserted this:



<query>
          <!&#91;CDATA&#91;select e from myproject$Projects e&#93;&#93;>
           <filter>
                <and>
                     <c>e.method.name like "the xy method%"</c>
                </and>
           </filter>
</query>

And unfortunately when I want to open this screen I get:

“Internal error
Please notify the administrator.
Pay attention to any unsaved data, and click here to continue.”

Do I need to do something else? Insert some code to somewhere else?

What is in the log file? (deploy/tomcat/logs/app.log)


2017-05-24 15:35:51.980 ERROR &#91;http-nio-8080-exec-15/myproject/admin&#93; com.haulmont.cuba.web.log.AppLog - Exception in com.haulmont.cuba.web.toolkit.ui.CubaMenuBar: 
com.haulmont.cuba.core.sys.jpql.antlr2.JPA2RecognitionException: line 1:37 no viable alternative at character '"'
	at com.haulmont.cuba.core.sys.jpql.antlr2.JPA2Lexer.emitErrorMessage(JPA2Lexer.java:4604)
&#91;...&#93;

I tried to expand the Datasource’s query like:


select e from myproject$Projects e where e.method.method like "%the xy method%"

But I got the same error, in log:



2017-05-25 11:01:34.270 ERROR &#91;http-nio-8080-exec-2/myproject/admin&#93; com.haulmont.cuba.web.log.AppLog - Exception in com.haulmont.cuba.web.toolkit.ui.CubaMenuBar: 
com.haulmont.cuba.core.sys.jpql.JpqlSyntaxException: Errors found for input jpql:&#91;select e from myproject$Projects e where e.method.method like "%the xy method%"&#93;
line 1:84 no viable alternative at character '"'
	at com.haulmont.cuba.core.global.QueryParserAstBased.getQueryAnalyzer(QueryParserAstBased.java:82)
 

Use single quotes for the string inside JPQL:


<c>e.method.name like 'the xy method%'</c>