Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've written a feature that deploys new columns along with a content type containing the columns. The feature is Site scoped and written in Visual Studio 2010 to deploy to SharePoint 2010.

When the feature is deployed the new columns and content type show up in the UI, however the content type is missing the new columns. I first suspected that the content type was being deployed first followed by the columns.

Update:

I followed Koen's blog post. His approach is to add the fields to the start of the content type's elements.xml. The steps in his post worked perfectly! However when I tried to follow the same approach with the content type I'm working on, the site columns were deployed correctly but still not the content type!

I've done a lot of testing and may be confused now about what's actually happening. Here is the complete elements.xml I'm using:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- High Importance -->
  <Field ID="{5FFCA09E-EF49-11DE-96C7-B58E56D89593}" Name="HighImportance"
         Group="AA Site Columns" DisplayName="High Importance" Type="Boolean">
    <Default>0</Default>
  </Field>
  <!-- Show On Home -->
  <Field ID="{A8A659D4-42DC-409f-817F-A97DFC5694E6}" Name="ShowOnHome"
         Group="AA Site Columns" DisplayName="Display on Home" Type="Boolean">
    <Default>1</Default>
  </Field>

  <!-- Parent ContentType: Announcement (0x0104) -->
  <ContentType ID="0x010400C01C3EAAEF4211DEA475A36356D89593"
               Name="Intranet Announcement"
               Group="AA Content Types"
               Description="Test content type deployment."
               Inherits="TRUE"
               Version="0">
    <FieldRefs>
      <!--  Start Date -->
      <FieldRef ID="{64cd368d-2f95-4bfc-a1f9-8d4324ecb007}" Required="TRUE" />
      <!--  Expires -->
      <FieldRef ID="{6a09e75b-8d17-4698-94a8-371eda1af1ac}" Required="TRUE" />
      <!--  High Importance -->
      <FieldRef ID="{5FFCA09E-EF49-11DE-96C7-B58E56D89593}" />
      <!--  Show on home -->
      <FieldRef ID="{A8A659D4-42DC-409f-817F-A97DFC5694E6}" />
    </FieldRefs>
  </ContentType>
</Elements>

Can anyone else deploy this correctly or see the problem here?

share|improve this question
    
i have same problem, you can't write comments in <FieldRefs> tag... –  user11149 Oct 5 '12 at 8:54

7 Answers 7

I have created a blog post on how to deploy a content type and its fields on SharePoint 2010 using Visual Studio 2010. Can you check if my approach is similar to yours?

http://www.koenvosters.be/post/howto-build-a-deployable-content-type-for-sharepoint-2010.aspx

share|improve this answer
    
This works when I follow your steps. When I follow them with the columns and content types I need to use however they don't work. Still looking into why... –  Alex Angas May 23 '10 at 13:15
    
+1 as your answer helped me the most. I've also given the answer that seems to solve the problem. –  Alex Angas May 24 '10 at 23:45
up vote 2 down vote accepted

I've found this functionality to be quite buggy (there are several other problems not mentioned here that I've had). However this seems to be a reasonably reliable way to resolve this issue:

  1. Create the columns and content type in the UI.
  2. Save site as a WSP site template (turn off Publishing site feature first to see this option if necessary).
  3. Import the WSP into Visual Studio and only select the fields and content types that are needed.
  4. Copy the resulting XML into your original project and combine the field and content type definitions. The field definitions should be first in the elements.xml.
share|improve this answer

You should be able to deploy a site column and a content type in the same Feature just fine, as both as Site-scoped. I'm doing this without any problems.

Make sure in your Feature that the site column is 'before' the content type, since things get executed in the order they are presented to SharePoint. In the Feature Designer, there are 'Up' and 'Down' arrows for this purpose to the right of the right-hand pane - they're easily missed :)

share|improve this answer
    
Hmmm I can find them when working with the package but not the feature? In any case, I added the elements to the feature in the correct order and checked its manifest file to ensure the order was correct. Still no luck! –  Alex Angas May 23 '10 at 12:00

The problem is caused by the XML comments in the "FieldRefs" - i.e "Start Date" . Remove them and all will work as expected.

Just wasted 3 hours of my life wondering what the hell was going on - thanks SharePoint!

share|improve this answer
    
Really??!! Wow I hope you are right. When I can test this again I'll come back and try it out. –  Alex Angas Sep 1 '10 at 2:24

Bit of a no-brainer here but I assume you have checked the <FieldRefs> within the generated Element Manifest to ensure your fields are included.

share|improve this answer
    
Good suggestion! All checked out OK [avoids egg on face]! –  Alex Angas May 23 '10 at 11:47

I like to separate my site columns from my site content type. And like Chris said, make sure the fields are provisioned before the content type. Just create a second element manifest and move your content type into that.

Also make sure the Ids match on the fieldrefs and the fields.

share|improve this answer

I think here is another solution. Remove all listelement from the list. also make sure that the elements are removed from the recycle bin.

The recycle bin was the point in my case :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.