tags:

views:

699

answers:

1

Is it best to create sharepoint lists in a feature using xml (schema.xml) or using custom code which create the list using the API?

I ask because I would expect the declarative approach to be the easiest, but according to all tutorials I have found it seems I have to create an enormous schema.xml file by copying and modifying an existing schema.xml or by generating it automatically from an existing list. The schema.xml seems to contain a lot of redundant data.

Edit: I'm talking about a custom list with custom columns.

+5  A: 

Schema.xml is a mess. You should use it if you want control over the various views, or if you want the user to find your custom list on the "Create list" page. Otherwise I would create a list with a standard template, and add columns as needed, all in code. (Remember to also add the columns to the appropriate views.)

Another reason to use code is if you want to use a lookup field. I haven't found a good way to set the target list in xml.

That said, it isn't difficult to use schema.xml. The disadvantage is esthetic: You're adding a large amount of data to your project, most of which you'll never want to touch, and will frighten future maintainers. Code is clean.

Bjørn Stærk