views:

1549

answers:

2

Hello.

Trying to use features to deploy custom fields, content type and list. So far I have a content type referencing custom and builtin fields. Content type inherits Item (0x01).

Now, I create custom list definition that references content type and fields (builtin and custom ones). I explicitly set ShowInDisplayForm, ShowInEditForm, ShowInNewForm values to true, however when I deploy feature and create list based on definition, all I get is only a single Title field in all forms!

However if I add field from UI to the list, it shows up in the form! Furthermore, if I create custom list from UI and add the content type, those fields are showing up in forms!

What's up with that?

By the way, I use VSeWSS tool for Visual Studio so it already genrates alot of stuff correctly.

Some code:

<ContentTypes>
  <ContentTypeRef ID="0x01003420C661289843dbAB9E41F43C23BFD0" />
</ContentTypes>
<Fields>
  <Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" Group="$Resources:core,Extended_Columns" Required="TRUE" ShowInDisplayForm="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE" Type="Text" Sortable="TRUE" Filterable="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />
  <Field ID="{B4629012-C672-4911-B0D0-B9CB2DA44ED2}" DisplayName="Jautājumu pacēla" Group="$Resources:core,Extended_Columns" Name="QuestionRisedBy" Required="TRUE" ShowInDisplayForm="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE" Type="User" Sortable="TRUE" Filterable="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />
  <Field ID="{6DF9BD52-550E-4a30-BC31-A4366832A87F}" DisplayName="Komentārs" Group="$Resources:core,Extended_Columns" Name="Comment" AppendOnly="TRUE" Required="FALSE" NumLines="12" Type="Note" ShowInDisplayForm="TRUE" ShowInEditForm="TRUE" ShowInNewForm="TRUE" Sortable="FALSE" Filterable="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />
  <Field ID="{FC072586-E8BB-444f-AAA4-8D5745FBC096}" DisplayName="ParentItemId" Group="$Resources:core,Extended_Columns" Name="AgendaParentItemId" Required="TRUE" Type="Integer" Sortable="FALSE" Filterable="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />
  <Field ID="{29207E42-E107-4379-B620-BAAFC461276B}" DisplayName="AgendaRootItemId" Group="$Resources:core,Extended_Columns" Name="AgendaRootItemId" Required="TRUE" Type="Integer" Sortable="FALSE" Filterable="FALSE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />
  <Field ID="{06063FDB-3C2A-4141-91F7-28C2739CE6B5}" DisplayName="AgendaItemClosed" Group="$Resources:core,Extended_Columns" Name="AgendaItemClosed" Required="FALSE" Type="Boolean" Sortable="TRUE" Filterable="TRUE" SourceID="http://schemas.microsoft.com/sharepoint/v3" />
</Fields>
A: 

Hi Janis

I can see you got the part were most people get problems right (Putting all the fields into the list), but does your ContentType definition include FieldRef's for all the fields?

Per Jakobsen
A: 

Hello. Yes, ContentType has FieldRefs for all the fields (Well, not inherited ones). However I read that when defining contet types in schema.xml, you must explicitly define Field`s also (that's weird), however if you add ContentType programmatically, then it correctly adds CType fields to definition.

By the way, what you see is what VSeWSS (microsoft extension for VS) tool generated (all the references).

Quite from SharePoint blog:

What you need to do is to add the exact same elements to the element as in the content type, including the same ID. This is a little strange, but in fact you need to define the fields twice, both in the content type and in the schema.xml to make this work. You can skip the Group and a few other properties.

However if I won't use Fields, I`ll get an exception:

[COMException (0x80004005): Nevar pabeigt šo darbību.

Lūdzu, mēģiniet vēlreiz.]
   Microsoft.SharePoint.Library.SPRequestInternalClass.GetViewsSchemaXml(String bstrUrl, String bstrListName, Boolean bFullBlown, ISP2DSafeArrayWriter p2DWriter, Int32& plDefaultViewIndex) +0
   Microsoft.SharePoint.Library.SPRequest.GetViewsSchemaXml(String bstrUrl, String bstrListName, Boolean bFullBlown, ISP2DSafeArrayWriter p2DWriter, Int32& plDefaultViewIndex) +122

Oh, well, anyway, I read somwhere an article (can't find that article no more)that suggest adding content type with feature receivers, then it properly shows up fields in forms.

Janis Veinbergs