How do I pass a date, relative to the current date, into a Query Filter?

I'm creating a new Content View. I want to select documents where a date field (rule:Rule-ExpiringDate) is less than the current date plus 30 days. In other words, all documents that will expire within 30 days from today, including those already expired.

In the the Studio Content View -> Query filter, I tried this:

QUERY FILTER:

ecm:mixinType != 'HiddenInNavigation' AND ecm:isCheckedInVersion = 0 AND ecm:currentLifeCycleState != 'deleted' and ecm:parentId= ? and rule:Rule-ExpiringDate <= DATE ?

QUERY PARAMETERS:

#{currentDocument.id}
@{currentDate.days(30)}

Resulting in this error in Nuxeo:

Failed to execute query: java.lang.IllegalArgumentException: Invalid format: "@{currentDate.days(30)}" in query: SELECT * FROM Document WHERE ecm:mixinType != 'HiddenInNavigation' AND ecm:isCheckedInVersion = 0 AND ecm:currentLifeCycleState != 'deleted' and ecm:parentId= '7af53f00-181c-45af-921d-ccdd3bf2bab2' and rule:Rule-ExpiringDate <= DATE '@{currentDate.days(30)}' ORDER BY rule:Rule-ExpiringDate DESC

What is the correct Query Filter and Query Parameters?

0 votes

1 answers

1658 views

ANSWER



Hi,

The filter looks ok, and first parameter too, but the second parameter is using the MVEL syntax as if you were in the context of an operation. You need to use JSF EL here (i know it's confusing…).

I'm not sure if you have a simple way of doing “@{currentDate.days(30)}” without writing code, but i can try to find out if you're still interested.

0 votes