Question

I'm trying to list all documents that were (ever) modified by a specific user, using a CAML query like this one:

var query = new CamlQuery{ ViewXml = 
  "<View Scope='Recursive'>" + 
    "<Query>" +
      "<Where>" + 
        "<Contains>" +
          "<FieldRef Name='Editor' LookupValue='TRUE' />" + 
          "<Value Type='Text'>Frank van Puffelen</Value>" +
        "</Contains>" + 
      "</Where>" + 
    "</Query>" +
  "</View>" };

On an item level there are the Editor and Author fields that seem promising. But unfortunately the Editor field seems to only identify the person who modified the most recent version, while I am looking for documents that were modified at any point by this user.

Say I have a document with this version history:

  1. John Doe
  2. Frank van Puffelen
  3. John Doe

Then the item will show "John Doe" as both its Author and its Editor. So this document will not show up when I search for items modified by "Frank van Puffelen" with the CAML query above.

So far the only way I've been able to get the necessary information is to open the version history of each item. But that is of course quite costly and I'd prefer to prevent it if possible.

Is there any way to search the version history using CAML like this? Or is there another search technique that would get me the list of documents that a specific user contributed to?

Was it helpful?

Solution

Frank, I don't think it's possible to do what you want. If search returned all of the versions, we'd have a real mess on our hands. You're right that the Author (Created By) is the original creator and the Editor (Modified By) is the last person who made an update. To add to the complexity, those roles may have only made changes to metadata and not the document itself.

If you need to be able to reliably get at what you seek, you'll need to make considerations in your architecture going forward to track the details along the way.

OTHER TIPS

The SharepointAudit logs keep track of that stoff if auditing is enabled on your site. You can use an SPAuditQuery to get all the Documents Frank van Puffelen updated. You could look at http://www.codeproject.com/Articles/431342/Auditing-A-Built-in-Feature-of-SharePoint

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top