0

I'm trying to update a publishing page in SharePoint 2010 with new Editor and Modified values, but the ones I pass (that I copy from another page) are not saved.

I've tried Update(), SystemUpdate(), UpdateOverwriteVersion() - nothing works. Is there a secret trick? I've tried the suggestions in other similar questions but the situations are a bit different.

Code snippet below:

...
$page = $web.Lists["Pages"].GetItemByUniqueId($uid)
$page["Editor"] = $e      # user from another page
$page["Modified"] = $m    # date from another page
$page.SystemUpdate($false)

2 Answers 2

0

This simple example works for me:

$web = Get-SPWeb 'http://aissp2013'
$list = $web.Lists["Pages"]
$page = $list.GetItemById(4)
$user = $web.EnsureUser('contoso\aaronp')
$page["Editor"] = $user   
$page["Modified"] = '11/14/2014' 
$page.SystemUpdate()
0

Five years ago I created a custom field type to support changing those props from the UI. I've based my solution on the code sample found here:

SPListItem item = ...; 
item["Created By"] = web.EnsureUser("luisb").ID; 
item["Modified By"] = item["Modified By"]; 
item["Created"] = DateTime.Now.AddYears(-3); 
item["Modified"] = DateTime.Parse("01/01/2000"); 
item.UpdateOverwriteVersion();

As you can see, it utilizes the UpdateOverwriteVersion method, and not the Update / SystemUpdate methods.

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.