Skip to main content
Boman.Biz

Boman.Biz

Go Search
Home
Mobile Monger
  

Boman.Biz > Posts > HOWTO: Fake the author information for documents in SharePoint
HOWTO: Fake the author information for documents in SharePoint

 

When migrating data into SharePoint it is sometimes necessary to upload pages/documents and set the Created and Modified information.

This can be difficult with minor versioning turned on, so in my case I was able to temporarily switch off Minor version while updating the lists and then turn it back on again.

To actually set the Created and Modified information with out leaving any footprints can be a little tricky, but this is how I did it:

sppTargetPage.CheckOut();

//Get the underlying list item
SPListItem sliTargetPage = sppTargetPage.ListItem;

//Set the publishing contact.
sppTargetPage.Contact = <SPFieldUserValue>;
//Check-In
sliTargetPage.File.CheckIn("Checked in by Data Migration", SPCheckinType.MajorCheckIn);

//Stealth Extra update to set modification date/time
SPListItem sliStealth = sliTargetPage.ParentList.GetItemById(sliTargetPage.ID);
sliStealth[SPBuiltInFieldId.Created] = <Fake Create Date> ;
sliStealth[SPBuiltInFieldId.Created_x0020_By] = <SPFieldUserValue>;
sliStealth[SPBuiltInFieldId.Modified_x0020_By] = <SPFieldUserValue>;
sliStealth[SPBuiltInFieldId.Modified] = <Fake Modified Date>;


//Creates new version if minor versioning turned on.
sliStealth.UpdateOverwriteVersion();

Comments

There are no comments yet for this post.

Title


Body *


From *


(not rendered on the page)

If you are commenting to add SPAM - what is your motivation? *

Attachments