0

I'm currently updating a single property on a file (called "Website Link"). As this is updated by an automated event I don't also want to update the file metadata in the process. At the moment I'm doing this by capturing the modified and modified in variables and then saving it back to the item before I do UpdateOverwriteversion() - it makes for some confusing code though. For example:

var spFile = web.GetListItem(_listUrl + item.Name);

var currentModified = spFile["Modified"];
var currentModifiedBy = spFile["Modified By"];

spFile["Website Link"] = hyperlink;
spFile["Modified"] = currentModified;
spFile["Modified By"] = currentModifiedBy;

spFile.UpdateOverwriteVersion();

Surely there's a better way than this?

1 Answer 1

2

You'd SystemUpdate like this:

var spFile = web.GetListItem(_listUrl + item.Name);
spFile["Website Link"] = hyperlink;
spFile.SystemUpdate();

https://msdn.microsoft.com/en-us/library/office/microsoft.sharepoint.splistitem.systemupdate.aspx

Updates the database with changes that are made to the list item without changing the Modified or Modified By fields.

1
  • Thought there would be something simple like this just couldn't find it, thank-you!
    – Michael A
    Commented Jun 23, 2015 at 4:20

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.