Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to rename a folder in a Sharepoint document store through a web application.

Changing the folder name works fine, but the name of the editor became the service user running the web application. I want to set the editor to the actual user who wanted to change it.

 //get the user, and the folder
 var user = clientContext.Web.EnsureUser(userLogin);
 //camlDirectorySelect is a CamlQuery to get the directory...
 var folders = spsList.GetItems(camlDirectorySelect);
 clientContext.Load(folders, x => x.Include(y => y["Title"], y => y["FileLeafRef"], y => y["Editor"], y => y["CheckoutUser"], y => y["Modified_x0020_By"]));
 clientContext.ExecuteQuery();

 if(folders.Count == 1) {
    var theFolder = folders[0];

    theFolder["Title"] = renameParams.NewDirName;
    theFolder["FileLeafRef"] = renameParams.NewDirName;

    theFolder["Author"] = user; //The 'Author' does change
    theFolder["Editor"] = user; //But 'Editor' will be the user executing the code (running the web app)...
    //tried this too, but no luck: theFolder["Editor"] = String.Format(@"{0};#{1}", user.Id, user.Title);
    theFolder.Update();
    clientContext.ExecuteQuery();
 }

A similar method works perfectly for files, and I can change the 'Author' for folders too. Any ideas?

share|improve this question
add comment

1 Answer

From my experience, changing the Author or the Editor name isn't supported on client object model. So the next best thing is just to create your own custom web service\wcf service and update those fields on the server side. Here's a nice tutorial on how to create a custom wcf service.

Good luck,

Alex Choroshin.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.