Sunday, April 28, 2013

Working with SharePoint Content Types

Recently I had some strange experience while working with Sharepoint Content Types. I used Content Types while creating a custom workflow for Sharepoint 2010 using Visual Studio. The Content type was defined with various fileds with display names, internal field name and their respective unique GUIDs. The workflow was good and got deployed successfully in a site collection. Again, I had to create a new workflow which was suppose to use the same list column names. So I thought of using the same Content Type with same Content Type ID, field names, etc. actaully, the entire xml file schema which contains the defenition of that content type was resued in this new new workflow. Now this workflow was deployed in the same web application but on the different site collection. So it was something like this:

WebApplication : http://myWebApplication:1234

Site Collection1 : http://myWebApplication:1234/GCIndia/ - Uses Content Type .. WorkflowContentType1

Site Collection2 : http://myWebApplication:1234/GCAsiaPacific/ - Resues the above content type

I resued the same content type because the workflow was suppose to have same feild values and also sam e names had to be included.

Now when I deployed the second workflow both the Content types should have been deployed in their respective site collections but to my surprise I was unable to activate the feature which was suppose to activate second workflow's reused content type. I was surprised to see to what happened as both these site collections had different content databases. This was because Site Collection1 was created and migrated from Sharepoint 2007 and Site Collection2 was created using Sharepoint 2010 environment post migration.  Ideally both the content types shoould have worked correctly becuase they were residing in differnet content database. I tried to recreate this scenario in my Dev box by taking the backup of relevent production data in to it. Then I was able to see both the deployments working. Now the conclusion is that the Databases have been merged at the production level as Microsoft does not all same content type ids to be used in two Content type defenetion.

Continued...