Getting metadata properties from FileVersion object

Brass Contributor

Hello,

I've actually posted this on uservoice here (https://sharepoint.uservoice.com/forums/329220-sharepoint-dev-platform/suggestions/15817876-expose-m...), but maybe there's a way to do this that I'm not aware of...

 

We've migrated some files to SharePoint Online from SharePoint 2010.  The SharePoint Online environment does not have the same users as the SharePoint 2010 environment. When the files were migrated, we can still see the names of the people who last modified the document, and also for each version.  This is great!

 

However, I would like to read those names using CSOM.  The "CreatedBy" user comes acrosss as null. I can actually do this against the (current) file, but I can't find a way to do this against the FileVersion object:

 

// load file, ctx is a ClientContext object
var file = ctx.Web.GetFileByServerRelativeUrl("[FILEURL]"); 

// ctx.Load(file, f => f.CreatedBy );  does not work, CreatedBy user cannot be found
ctx.Load(file, f=> f.Properties); // works
ctx.ExecuteQuery(); 
var x = file.Properties["_vti_modifiedby"]; // <-- this works, and I can see the user name

//ctx.Load(file, f=> f.Versions.Include(v => v.CreatedBy); does not work, user cannot be found
ctx.Load(file, f=> f.Versions);
ctx.ExecuteQuery();
foreach (var v in file.Versions)
{
      // wouldn't it be nice if the below worked:
     var z = v.Properties["_vti_modifiedby"];
      // but there is no Properties object
}

Is there a clean way to do this? If not, can I shamelessly plug my UserVoice request above?

0 Replies