Tuesday, June 25, 2013

SharePoint 2010 Content Type Issues

I've been working on a project where I had two document libraries (one upload library and one archive library) and a number custom Site Content Types. We have an event receiver on the upload library that will sometimes move the document (using the C# API SPListItem.File.MoveTo method) to the archive library.

Here's what we saw happening:

We had content type Child which was based on content type Parent. When in the upload library, the document was categorized as Child. When the event receiver moved it to the archive library it would arrive as content type Parent. This made no sense!

We stepped through the code and there was nothing at all that indicated a problem with our event receiver. It was truly happening inside the MoveTo function, so it seems to be a SharePoint bug.

Our only solution was to change recreate the Child content type (as Child2)so that it didn't inherit from Parent and instead inherited from something else (like document). Once we created Child2, we then changed all the documents of Child to Child2. Then we removed the Child content type from both libraries, and deleted the site content type. Finally we renamed the Child2 site content type, and then the instances of that content type in each libary.

Problem solved!

No comments:

Post a Comment