Sunday, March 30, 2008

Change approval status without changing ModifiedBy property on a document

We have created a copy-paste utility for SharePoint 2007 which enables documents to be moved from one place within SharePoint to another.

When we move or copy the file we include properties as well as versions with Createdy, ModifiedBy, TimeCreated and TimeLastModified. Everything works fine except for one issue.

When we publish a document using SPFile.Publish() the ModifiedBy and TimeLastModified are changed - therefore we lose the version history.

Instead we try to fix the issue using the comment field - somehow it solves part of the issue but we would appreciate a better solution.



We have tried changing

oFile.Publish([comment])

to

oFile.Item.ModerationInformation.Status = SPModerationInformation.Approved

oFile.Item.ModerationInformation.Comment = [comment]

oFile.Item.SystemUpdate(false)

but unfortunately ModerationInformation is not available on the SPFile object.

This blog mention the same issue - without a solution. Ideas appreciated.

As our last resort we're currently investigating creating a stored procedure which modified the SharePoint SQL database behind the scene. We would prefer not using this solution (albeit it works).

Monday, March 24, 2008

One of more field types are not installed properly

If you have ever come across the error One of more field types are not installed properly then you know it isn't easy to fix. If it happens in a query download the U2U CAML Builder as described in the blog.

Unfortunately I get the error when I try to delete the field from SharePoint using oDocLib.Fields.Delete(). Any ideas why this happens would be appreciated.

Fortunately this blog gave me some hints.