NXQL query for locked documents

Looking for a way to query for locked documents of a particular type.

I've tried variations on this:

SELECT * FROM Document WHERE ecm:primaryType = 'DocumentType' AND ecm:lockOwner IS NOT NULL

including

SELECT * FROM Document WHERE ecm:primaryType = 'DocumentType' AND (ecm:lockOwner IS NOT NULL or ecm:lockOwner <> ' ')

To test the query syntax I am working in a pre-production environment where I know that some but not all of the documents of the desired types are locked. Regardless of how I word the query, I either get back all of the documents or none of the documents, not the desired subset.

Any suggestions or help is appreciated.

0 votes

2 answers

111 views

ANSWER



Hello,

Try with ecm:isCheckedIn = 0 to find locked documents :)

More on https://doc.nuxeo.com/nxdoc/nxql/#special-nxql-properties

Regards

0 votes



I tried your query and the first option worked correctly for me:

SELECT * FROM Document WHERE ecm:primaryType = 'DocumentType' AND ecm:lockOwner IS NOT NULL

That query returned the 1 document I had locked of the specified doctype in the NQXL.

If I use the option for isCheckedIn then it returns all the documents of the specified doctype, not sure why but it doesn't seem to acknowledge that a locked file is checkedOut.

SELECT * FROM Document WHERE ecm:primaryType = 'DocumentType' AND ecm:isCheckedIn = 0

I tested this in my local environment which is LTS 2021 (hotfix 10). If your first query is not working, then maybe it has to do with the database you are using?

0 votes



TBH I'm not sure if it was a database issue or something else, but whatever the case, some of these attributes such as ecm:lockOwner and ecm:isCheckedIn were not updating to the database properly for locked documents. I was able to find a solution though.
11/03/2021