views:

103

answers:

1

I'm working with a customer that needs to migrate documents from their current document management system (not Sharepoint) into Sharepoint MOSS 2007 retaining document history and metadata. I've written a proof of concept using the Sharepoint web services and that looks promising, but the snag so far seems to be programmatically setting the created date/time and user. The webservices allow the fields to be set but implicitly override them to be the currently logged in user + date/time. For obvious reasons, I need to be able to keep the original created date/time and user on migration. Does anyone know the best way to approach this problem?

A: 

Have you tried programmatically adding the document and then updating those fields? Perhaps you could even do this directly on the object in SP2K7 Database if you have the object id.

Here's an article that might be able to help you out a little.

http://www.eggheadcafe.com/software/aspnet/29904945/change-modificationcreat.aspx

Dim vLocalFileName As String
Dim file As SPFile
pLocation = "http://myserver/Docs/Documents/TestDoc.doc"
vLocalFileName = "C:\TestDoc.doc"
Dim site As SPWeb = New SPSite("http://myserver/Docs").OpenWeb()

Dim fStream As FileStream
fStream = New FileStream(vLocalFileName, FileMode.Open)
Dim contents(fStream.Length) As Byte
fStream.Read(contents, 0, CInt(fStream.Length))
fStream.Close()

file = site.Files.Add(pLocation, contents)
Dim ListItem As SPListItem
ListItem = file.Item
ListItem("Title") = "updatetest"
ListItem("MyLookupField") = "1"
ListItem("Created") = "2007/01/01 10:00"
ListItem("Modified") = "2007/01/01 11:00"
ListItem.Update()

file.CheckIn("", SPCheckinType.MajorCheckIn)
hunter
so it looks like you can upload the document, manipulate those fields, then check in a new version. I'm guess you would want this to be on the single version but I don't think this is a bad approach. It might be good to know how that document originally got there via your migration process.
hunter
Thanks Hunter. I'll check it out + update with my results.
Jeramie Mercker