As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
Hi!
In Nuxeo 6.0 HF 38 I'm trying to use CurrentDate in NXQL in avanced search or by quering http://nuxeoserver/nuxeo/api/v1/query
When I try this, it works: http://nuxeoserver/nuxeo/api/v1/query?query=SELECT * FROM Document WHERE dc:created > TIMESTAMP '2017-04-04 00:00:00'
But this doesn't work : http://nuxeoserver/nuxeo/api/v1/query?query=SELECT * FROM Document WHERE dc:created > TIMESTAMP '@{CurrentDate.days(-1).format("yyyy-MM-dd HH:mm:ss")}'
I get this error : {"entity-type":"exception","code":"org.nuxeo.ecm.webengine.WebException","status":400,"message":"Failed to execute query: java.lang.IllegalArgumentException: Invalid format: "@{CurrentDate.days(-1).format("y..." in query: SELECT * FROM Document WHERE dc:created > TIMESTAMP '@{CurrentDate.days(-1).format("yyyy-MM-dd HH:mm:ss")}'"}
Thanks for help.
Hi, did you try: "SELECT * FROM Document WHERE dc:created <= DATE '@{CurrentDate.format("yyyy-MM-dd HH:mm:ss")}'"
Or you can have a look to https://answers.nuxeo.com/general/q/23699bc926634b439b552c3848e12ad1/How-do-I-pass-a-date-relative-to-the-current-date-into-a-Query-Filter
Hi Saimir,
With this : http://nuxeoserver/nuxeo/api/v1/query?query=SELECT * FROM Document WHERE dc:created <= DATE '@{CurrentDate.days(-1).format(“yyyy-MM-dd HH:mm:ss”)}'
I got the same error : {"entity-type":"exception","code":"org.nuxeo.ecm.webengine.WebException","status":400,"message":"Failed to execute query: java.lang.IllegalArgumentException: Invalid format: "@{CurrentDate.days(-1).format(“y..." in query: SELECT * FROM Document WHERE dc:created > DATE '@{CurrentDate.days(-1).format(“yyyy-MM-dd HH:mm:ss”)}'"}
When I use this query (the same in my first question) in an automation chain it works : SELECT * FROM Document WHERE dc:created > TIMESTAMP '@{CurrentDate.days(-1).format(“yyyy-MM-dd HH:mm:ss”)}'
but it dosen't work in the API Url nor in NSQL Advanced search.
Thank you.
Hi, You can't access mvel ( "@{CurrentDate.days(-1)") function here because at this point it is out of context. I suggest You to build some client code witch will call the rest service
OK that's why. Thank you Saimir for your help.
you're welcome