0
votes

When I assign one of my content types to a document library, the last column defined in this content types is missing in the list of library columns. It is defined as

<Field
   Type="Choice"
   DisplayName="Document Class"
   EnforceUniqueValues="FALSE"
   Indexed="FALSE"
   MaxLength="255"
   Group="Project Site Columns"
   ID="{xxx...x}"
   StaticName="prj_document_class"
   Name="prj_document_class"
   ShowInNewForm="FALSE"
   ShowInEditForm="FALSE"
   ShowInDisplayForm="TRUE"
   ShowInViewForms="FALSE"
   ShowInListSettings="FALSE"
   ShowInFileDlg="FALSE"
   ShowInVersionHistory="TRUE">
   <CHOICES>
      <CHOICE>Public</CHOICE>
      <CHOICE>Private</CHOICE>
   </CHOICES>
</Field>

In the content type definition, the column is referenced as

<FieldRefs>
   ...
   <FieldRef
      ID="{xxx...x}"
      DisplayName="Document Class"
      Required="FALSE"
      Name="prj_document_class"
      Sortable="FALSE" />
</FieldRefs>

What am I doing wrong?

1
Check if there is another column has same id - Habib Adıbelli

1 Answers

0
votes

Have you added FieldRef to the Views in Schema.xml of your list?

Check your list's Content Types if they already have the required field. (Either with Sharepoint Manager or Powershell)

For powershell, try something like this:

$web = Get-SPWeb *site-url*
$list = $web.GetList(*list-url*)
$list.ContentTypes[*reqiured-content-type-index*].Fields.ContainsField(*field-name*)

If this function returns true, most likely your field is not in the required view.

If this function returns false try to add your field to the content type. Go to list settings -> manage content types. Choose 'Add a field from site columns'. If your field is really added to the site columns, you will be able to add it. Find it among the group you specified in Elements.xml of your field.

If you try to update a content type inside a testing environment and it's okay to lose all of the data, delete all of the lists associated with this content type. Then check both Recycle bins and clear all instances of your list and elements of that list. Then deactivate your feature. Check site content types and columns, your content type and columns must have disapeared. Only after this you should uninstall old solution and install new one.

It is also possible to update a content type with out losing all of the data, but it's a bit more tricky. The best way I know is to make one more feature, which will be your old feature updater. Make an event receiver for the new feature and inside FeatureActivated method add your new column to your site columns, content type, list and list's content type by using AddFieldAsXml method of SPFieldCollection (https://msdn.microsoft.com/en-us/library/office/ms457586.aspx)

I really hope this helps