0

The scenario is I want to retrieve column values(Item Value) of the list from version history and update only single column of item post.

Currently, I am not able to retrieve item object values but I am able to get Created by the user, Title etc field values.

Can someone please help me with it.

Thanks in advance.

  • What do you mean with item object values ? as What ? – Mohamed El-Qassas MVP Jul 16 '16 at 20:02
  • Here I mean is - from version history data I am not able to get field values. I need last modified values of fields. I hope this helps you. – user3386955 Jul 16 '16 at 20:09
  • In version history, I think the last modified value is the last version record value ! correct me if I am wrong – Mohamed El-Qassas MVP Jul 16 '16 at 20:15
  • Yes but I don't want to update last modified values of all field. I want to update just one column value so that I am not able to do. – user3386955 Jul 16 '16 at 20:20
  • There's a function "UpdateOverwriteVersion()" that overwrites the last version record via C# I will post the full code in the answer if it helps you please upvote and set it as the answer. – Mohamed El-Qassas MVP Jul 16 '16 at 21:14
0

I think you can achieve your scenario via Server-side Object Model C# to can update a column value in the Version history.

Code:

SPSite site = new SPSite("http://sharepointsite/subsite");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["My List"];
web.AllowUnsafeUpdates = true;
foreach (SPListItem item in list.Items)
{
  item["Modified"] = "Set the date";
  item["Created"] = "Set the date";
  item["Editor"]="itemCreatedUser";
  item.UpdateOverwriteVersion();
}

Note :

It is impossible to update the Modified By values in the Version History. The data of version history is stored in the SQL database, but it is not recommended to edit the data in the database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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