Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharepoint: What happens to lists based on content type when content type is updated?

I have kind of hypothetical question (at least for now :))

Let's say I create list based on some custom content-type. I add some 1000 items into that list (in production). Then customer comes and he say that he need to modify that custom content type.

What happens to list if I modify custom content type? Will it be updated automatically (I doubt) ? And what about already created list items?

Do any of you have some experience with this?

like image 756
Marian Polacek Avatar asked Jan 15 '09 11:01

Marian Polacek


People also ask

How do content types work in SharePoint?

A content type is a reusable collection of metadata (columns), workflow, behavior, and other settings for a category of items or documents in a SharePoint Server list or document library. Content types enable you to manage the settings for a category of information in a centralized, reusable way.

How do I update content type in SharePoint?

Go to the document library in which you want to update the content type with a document template. On the Ribbon, click the Library tab, and then click Library Settings. Under Content Types, click the name of the content type that you want to change.

What's changed in content type publishing?

In September 2021, we changed content type publishing to improve performance and make newly published and updated content types available to sites faster.

What is the purpose of content type in SharePoint?

A SharePoint content type pulls together an item and information about the item. The item might be one of many different kinds of files, a document, an excel workbook, or even a status indicator for a progress report. It could also be a list or a folder.


2 Answers

So a couple of issues regarding content types:

First of all, content types comes in two flavours: Site content types and list content types. Site content types are "templates" that reside in a gallery. When a site content type is used in a list, the content type is instantiated as a list content type on the given list.

Secondly, your content types could be created and modified in several ways, which would decide in what of three modes your data is present in the database.

If you have created the content type using the GUI, or through custom code using the API, both your site content types and your list content types are in the "database-only" state in the database. That means that it is looking in the database for the definitions of the content type.

If you have created the content type as a feature in CAML, your site content type is ghosted (or un-customized as we are supposed to call it in v3) in the database. That basicly means that the database looks in the feature XML in the 12-hive for the site columns that makes up the content type. So that should mean that you could update the feature, and you would have new site columns available in the update content type, right?

Unfortunately not: remember that we also had list content types? The bummer here is, that these list content types are instantiated using code, so they are in the "database-only" state. It means your changes would only be seen in your site content types, but not in existing lists using that content type!

There are several approaches to fixing this issue, the solution depends on what your needs are and what kind of changes you are doing (deleting fields, adding fields, changing fields).

For example, you would often want to keep your existing item meta data, even though the content type changes over time. If you push through the changes in the list content type through code, you would lose the data stored in the changed/deleted fields. A solution to this would be to add a completely new content type based on the old one but with the changed fields. You would add the new content type (through code or using feature XML) and use a feature receiver or similar to propegate the new content type to all lists that used the old content type, and subsequently mark the old content type as hidden. That would make it possible to keep old meta data but not to add new items using other than the new meta data.

The approach mentioned in the other answer to this question would be preferred if you have direct access to the production environment, and if your customers governance plan allows it. As with other artifacts in SharePoint however, it would be recommended to deploy content types in a structured manner. Adding new content types in an unstructured fashion would influence search relevance (managed properties) and could also affect the general taxonomy of the site (site columns not being reused, etc.), so even though it is possible to add these changes directly in a production site, I would not reccomend it!

That leads me to the final approach that is the one I would reccomend, at least for future content types: Create your content types programmatically from the beginning using a feature receiver! That way you always know the true state of your content types (database-only) and you can have a structured approach for governing changes in the future! You can find several ways to do this by googling 'create "content types" programmatically SharePoint'

For completeness: I mentioned three modes. The last mode your content type can be in is "UnGhosted". This means that your content type was created using feature XML, but that it has been disconnected from the original XML source in the 12 hive.

My friend Søren Nielsen has some good points on Content Types in Audit your Content Type Hierarchy. Some of the issues described above can be found briefly mentioned in an MSDN article Updating Content Types. Gary Lapointe also has an STSADM extension that addresses some of the problems with Content Types, see Propagate Content Type Changes.

Sorry for the rant, but the subject is complex and demands a thorough explanation to avoid any misconceptions.

like image 57
Anders Rask Avatar answered Oct 11 '22 15:10

Anders Rask


When you update the content type there is a checkbox you can click to update child content types. By checking that box the list content types will be updated.

Note that if you do not check the box to update child content types then there is no way to force the update later. Thus, if you don't update and later wants child content types to have the update you first need to reverse the update and the reaply it.

.b

like image 37
Bjørn Furuknap Avatar answered Oct 11 '22 16:10

Bjørn Furuknap