Sitecore Query XPath for Finding all Locked Items


Do you need to find all items in Sitecore that have been locked by any user? Below is an XPath query that will show you just that. Keep in mind that depending on the number of items in your installation, this query could take quite a while. I would not recommend running it in your code in a production environment, but rather using the XPath Builder to find these items and resolving them manually.

/sitecore//*[@__lock!='' and @__lock!='<r />']

How Does it Work?

Let’s break down the components of the query:

/sitecore//*[@__lock!='' and @__lock!='<r />']

Start at the root of the content tree: the sitecore item.

/sitecore//*[@__lock!='' and @__lock!='<r />']

Look at all descendants (recursively check all children).

/sitecore//*[@__lock!='' and @__lock!='<r />']

Only return items whose __lock field is not empty and does not contain <r />, signifying that a lock has been cleared.

Issues or suggestions? Sound off in the comments.

5 thoughts on “Sitecore Query XPath for Finding all Locked Items

Add yours

    1. Yes, you certainly could have. There is a field (lock) that is populated by the computed field Sitecore.ContentSearch.ComputedFields.IsLocked that is set to true when the item is locked. See below for the query you want:

      (lock:true AND _latestversion:true)

      The _latestversion:true part is important if you only want to return cases where the latest versions were locked.

  1. Thanks for sharing. Have you tried plugging this query in the Get-Item command found within Sitecore PowerShell Extensions?

Leave a Reply

Powered by

Up ↑

%d bloggers like this: