Document query casting error?
I've done the following query two ways:
Using parent/child in Studio.
Using NXQL query in Studio and get the same error. Here is the NXQL.
SELECT * FROM Document WHERE ecm:isCheckedInVersion = 0 AND ecm:parentId = '@{Context[“TRAVELERID”]}' AND ecm:primaryType = '@{Context[“NEXTRECIPEDOCTYPE”]}' AND ecm:currentLifeCycleState = '@{Context[“NEXTRECIPESTARTSTATE”]}'
All of the context variables resolve correctly in both cases. I have used similar queries in content views with success.
I get the following error:
org.nuxeo.ecm.automation.core.collectors.DocumentModelCollector cannot be cast to org.nuxeo.ecm.core.api.DocumentModel
I basically have a container document that has just made a state transition and I want to select one of the documents in the container. The query is trying to retrieve the “now active” document context so I can edit the metadata.
Any suggestions on what is wrong and how to troubleshoot this effort!?
I found the automation chain I was calling did not return a document this was by my design. I was using Run Document Chain which expects a document or documents to be returned. Since nothing was returned (the end result of the called chain was a task being queued) the casting error was thrown.
The Fix:
Changing the the Automation command to Run Chain fixed the casting issue.
I placed a List filter after the call but it does not seem to have any effect on the error.
Am I correct in my analysis of this bit of code?