none
replace list content type with site content type RRS feed

  • Question

  • I have an interesting situation.  I want to substitue a list content type for a site content type.  I created a solution that uses site columns and site content types.  I have older content (webs) that have lists that don't use the new content types.  When I designed the site columns and content types, I was careful to reuse the internal names but I had to use new GUIDs.  I want to add the site content type to the list, remove the old list content type (Item, customized using GUI, not even a schema.xml file), and have the fields assume their site column counterparts.  I thought this might be possible based on how provisioning works.  Let me explain.

    When you create a list schema and specify the content type, you can create a new one or reference an exisiting one (site content type).  If you reference, at provisioning, the list instance creates a list content type that is a copy of the site content type with a new contenttypeid showing the proper heirarchy.  Also the fields are specified by the content type.  And if you use site columns, the fields are created from the content type.  Now these fields have unique names.  When the fields are created from site columns, their are created as list fields using the same GUIDs and same names as the site columns.

    I've noticed the internals of sharepoint seem to favor the use of internal names for fields, not GUIDs.  So I was thinking, if I add a site content type, it will specify site columns.  And because these site columns have the same internal names as existing list fields, the two content types (existing list ct, and newly copied list ct) would share the same fields and then I could remove the older content type.

    But it doesn't seem to work like that.  Instead, the provisioning treats the fields separately and uses the different GUIDs causing the new content type (the copy of the site content type) to provision a new set of fields (the site columns) instead of reusing the existing fields.

    I hope that made sense.

    Can someone explain why it works this way and if there is anything I can do to make it work the way I envisioned it to.  Or explain why my logic is flawed and what I should be doing instead.  The ultimate goal is to preserve content but use site columns and site content types for easier global management of enhancements to fields.


    Brian Bedard, MCTS - pioneeringsharepoint.blogspot.com - Twitter:@tigertoy

    Thursday, June 17, 2010 2:21 PM

Answers

  • The only way I've found to get a new site content type  to replace an existing list content type is to remove the list content type first, then delete the related columns to that list content type, and then finally add your new content type.

    I've noticed that when you add a site content type to a list with an existing list content type that contains the same fields, SharePoint pushes 0's 1's etc at the end of the new site columns to make them unique.  ie: "Document Status" will be "Document Status0" and if you push it in a 3rd time it will be "Document Status1"

    As for preserving content, the solution I proposed doesn't do that.  However, you might be able to go to datasheet view and copy all the metadata and then paste it once the content types are changed.  I'm not sure if this would work, so it would be a good idea to test this.

     


    Kevin
    Thursday, June 17, 2010 5:49 PM