views:

689

answers:

3

I am creating a list definition that includes three columns that are look-ups off of other lists. I would like these look-up lists to be populated with some data when they are created but they also need to be editable by the site content managers.

When I save a list as a list template via the list settings page it gives me the option of saving list content. If I download the .stp, rename to .cab, open, and view the manifest.xml file I see list content is saved in the Data node. I added this data node to the schema.xml file of my list definition, but when I create a list using the list definition the data gets ignored.

How can I have my list definitions come pre-populated with data?

A: 

The data in a lookup field is stored in the other list. So that data would not be pulled from the other list.

If you wanted this solution to be portable, you could create the lookup list(s) at the same time you create your main list, and then prepopulate it with whatever data you wanted. You just want to be sure to create the lookup lists first so that your lookup fields can find the list to connect to.

Nathan DeWitt
+1  A: 

You might like to create a feature instead. Make activating the feature, create all three lists.

http://blogs.msdn.com/karthick/archive/2006/11/28/wss-3-0-features.aspx

May help to start you on the way.

Nat
Actually all 4 lists are already in a feature, I was just hoping to avoid populating list contents via code.
Chloraphil
+1  A: 

The (partial) solution is the ListInstance element of the elements xml file.

Some helpful links:

http://blogit.create.pt/blogs/andrevala/archive/2008/06/17/SharePoint-2007-Deployment_3A00_-List-Instance-Features.aspx

http://msdn.microsoft.com/en-us/library/ms478860.aspx

EDIT: Note, this only creates a list with the specified data when the feature is activated. Lists created from the list template via the UI will not have any records.

Chloraphil
This solution worked for me. But, I want to allow users to create this list with default data. Is this possible?Thanks!
Vijay