Tuesday, May 21, 2013

How to use a List Definition for Sharepoint 2010 in VS 2010

When creating a list definition you have to create and edit two main files. They are the Elements.xml and Schema.xml. In the Elements.xml you have to add the <Fields> and <Content Type> elements. Then in the Schema.xml you have to refer them.

When creating the GUIDs for the Fields and Content types, you have to be careful because they have to be inherited. Then those GUIDs can be created using Tools-> Create GUID-> New-> 4th Option

This is the MSDN reference for creating a List Definition.
List Instances are the objects that can be used for creating instances of the list definition.

Update:

You can only change the schema.xml to create the List Definition. There first you have to add the <Content Type> then the <Fields> and <FiledRef>s. After that, in the <ViewFields> you can add the <FieldRefs> to determine, which <Fileds> should be viewed.
When creating the GUID for the content type ID you have to be careful. There you have to add the correct Item ID (You can find them in  C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\ctypes\ctypes.xml).

To create the ID for the Content Type, first add the ItemID (Eg: 0x01 for ContentTypes) then add the GUID without the hyphens. For FieldRef IDs also there are default IDs for fields like Title. They can be found in the wss xmls in the 14\TEMPLATE\FEATURES folder. As an example, field ID for the title field is fa564e0f-0c70-4ab9-b863-0177e6ddd247.

Update:

Filed Type IDs are here:


C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\FEATURES\fields\fieldswss3.xml

No comments:

Post a Comment