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.

5
  • What do you mean with item object values ? as What ? Commented Jul 16, 2016 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. Commented Jul 16, 2016 at 20:09
  • In version history, I think the last modified value is the last version record value ! correct me if I am wrong Commented Jul 16, 2016 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. Commented Jul 16, 2016 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. Commented Jul 16, 2016 at 21:14

1 Answer 1

1

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.

1
  • You are welcome, Is the problem has been solved ? Commented Jul 17, 2016 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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