Ritesh.Shaw

Hi,

I want to create a custom list template. I want the fields of this list to be the fields of ont of the custom content types I have created.

I created a custom content type as:

<ContentType ID="0x00887D1DB2B45C41d3838B42D69B5D1CE6" Name="MyCustomListType" Group="MyGroup" Description="MyCustomListType">
<FieldRefs>
<FieldRef ID="{E822A3F0-4AF1-4784-800C-6C54D5C80DC9}" Name="NewWindow" Required="False" />
<FieldRef ID="{CA035D5F-BDC4-4b18-A23A-92186B411C00}" Name="TeaserBody" Required="False" />
</FieldRefs>

</ContentType>

I schema.xml of my custom list is as follows:

<List xmlnsSurprisews="Microsoft SharePoint" Name="MyCustomList" Title="My Custom List" FolderCreation="FALSE" Direction="0" Url="Lists/Basic List" BaseType="0" EnableContentTypes="True" >
<MetaData>
<ContentTypes>
<ContentTypeRef ID="0x01">
<Folder TargetName="Item" />
</ContentTypeRef>
<ContentTypeRef ID="0x0120"/>
<ContentTypeRef ID="0x012000887D1DB2B45C41d3838B42D69B5D1CE6" />
</ContentTypes>

<Fields>

</Fields>

...

...

<ViewFields>
<FieldRef Name="NewWindow"/>
<FieldRef Name="TeaserBody" />

</ViewFields>

...

...

When I am creating a list from this template the content type is getting added to the list of associated content types of the list however none of the fields are getting added to the list.

Can anyone help me in identifying the source of the problem

Regards,

Ritesh



Re: SharePoint - Development and Programming Creating a custom list template using custom content types

Lars Haupt-Hansen

I think you need to add

<FieldRef ID="{E822A3F0-4AF1-4784-800C-6C54D5C80DC9}" Name="NewWindow" Required="False" />

<FieldRef ID="{CA035D5F-BDC4-4b18-A23A-92186B411C00}" Name="TeaserBody" Required="False" />

in the <Fields></Fields> part of schema.xml. My VPC is down at the moment so I cannot check, but try it out :-)

/lars






Re: SharePoint - Development and Programming Creating a custom list template using custom content types

Darrin Bishop

Lars is correct.

When you use the UI to add a Content Type to a list instance it will copy the needed fields to the list. In this scenerio there is no code that will run to copy the fields that Lars has listed. These need to be added in the list's schema's Xml.






Re: SharePoint - Development and Programming Creating a custom list template using custom content types

Ritesh.Shaw

Thanks guys,

I tried adding <fieldref> to <fields> however, columns are not added to the list, instead I get this error:

One or more field types are not installed properly. Go to the list settings page to delete these fields.

Any ideas what can cause this problem.

Is the content type I am trying to use in the list needs to be derived from any specific type of content type as I have derived it directly from the system 0x

Thanks,

Ritesh





Re: SharePoint - Development and Programming Creating a custom list template using custom content types

annielhy

Ritesh.Shaw wrote:

Thanks guys,

I tried adding <fieldref> to <fields> however, columns are not added to the list, instead I get this error:

One or more field types are not installed properly. Go to the list settings page to delete these fields.

Any ideas what can cause this problem.

Is the content type I am trying to use in the list needs to be derived from any specific type of content type as I have derived it directly from the system 0x

Thanks,

Ritesh

Hi, is it a must to derived a content type from item (0x01)

From SDK:

"You can assign content types to list items, documents, and folders. You can assign content types that inherit from the Document site content type only to libraries. Similarly, you can assign content types that inherit from the Item site content type only to lists. Content types that inherit from the Folder content type template can be assigned to either libraries or lists, because both can contain folders."





Re: SharePoint - Development and Programming Creating a custom list template using custom content types

Lars Haupt-Hansen

Hi

Finally got my VPC back up and found the case where I did the same. In my <fields/> I uses <field/> not <fieldref/> so try adding:

<fields>

<!-- ID is the GUID of the Field in the ContentType. Used to connect this list field with the content type field -->
<Field Name="NewWindow" DisplayName="NewWindow"
Type="Text" ID="{E822A3F0-4AF1-4784-800C-6C54D5C80DC9}" />
<Field Name="TeaserBody" DisplayName="TeaserBody"
Type="Text" ID="{CA035D5F-BDC4-4b18-A23A-92186B411C00}" />

</fields>

Remember to change the Type attribute to the right value.

/Lars






Re: SharePoint - Development and Programming Creating a custom list template using custom content types

Lars Haupt-Hansen

As Annielhy says I'd go for extending Item (0x01) so I'd change my ContentType Id to "0x0100887D1DB2B45C41d3838B42D69B5D1CE6"

/Lars




Re: SharePoint - Development and Programming Creating a custom list template using custom content types

Ritesh.Shaw

Thanks guys,

It helped... I can create the list successfully now!

Warm Regards

Ritesh





Re: SharePoint - Development and Programming Creating a custom list template using custom content types

Dennis Hee

Hi,

When you add the field into the list definition using the same GUID with the site field (supposingly created in prior), does it not return an error message when editing the field from the web

Den