Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Populating a list via Site Definition's onet.xml

  Asked By: Bhavini    Date: Feb 22    Category: Sharepoint    Views: 5975

I have a custom feature which installs an empty list Links list (and
a webcontrol which consumes the links in it).

I want to have a custom Site Definition which uses this feature AND
put items in the list.

I tried adding the following under the
<Configurations><Configuration><Lists> section:

<List FeatureId="00BFEA71-2062-426C-90BF-714C59600103" Type="103"
Title="MyControlList" Url="Lists/MyControlList">
<Field Type="URL" Name="URL">http://www.google.com,

This gives me an error:
The specified name is already in use.

A list, survey, discussion board, or document library cannot have the
same name as another list, survey, discussion board, or document
library in this Web site.

I'm guessing this is because the List already exists and anything in
the <Lists> section is trying to create an instance of the list.

Is there another way in the onet.xml file to create items in an
existing list?



6 Answers Found

Answer #1    Answered By: Duane Walton     Answered On: Feb 22

The Lists section  of the ONET.xml can only implement features that define a List
Template, while I suspect that your feature  implements a list  Instance. You are
on the right track, but you've got to take a step back. Instead of using the
GUID for your Feature in the Lists section substitute the GUID of a standard
LinksList. Then edit the MODULES section of the ONET.xml to add the ListView
webpart for your list to the default.aspx page. You don't need a custom  Feature
for this.

As an alternative, you could also try adding  your Feature to the ONET.xml by
creating a FeatureSiteTemplateAssociation to staple your feature to existing
site definition. However, I have seen some issues with timing in the past using
this approach when trying to add webparts to the page.

Answer #2    Answered By: Cassandra Cooper     Answered On: Feb 22

You're right. My feature  does implement an instance, because if the
feature is activated I always want an instance  of this list  to exist
(my custom  web control relies on a specific named list).

The problem is that I don't want this list to appear as a webpart on
my page. I just want the list to be created and get populated with
site-definition specific items. So, I don't think I can use the
Modules section  (at least the only examples I've seen just populate a
list in a webpart). Is there some other way to just populate an
existing list?

Answer #3    Answered By: Elaina Suarez     Answered On: Feb 22

You create  and populate the list  using the configuration section. The modules
section is only used if you want to add a web  part to the page. So just use the
configuration section  to instantiate the list template and add the data rows.

Answer #4    Answered By: Kacey Russo     Answered On: Feb 22

But that goes back to my original problem. Because the feature  is
creating an instance  of the list, the Configuration section  fails and
gives me an error.

I don't want to create  an instance of the list  in the onet.xml (since
activating the feature does that), I just want to populate it with
site def specific values.

Answer #5    Answered By: Rebecca Lewis     Answered On: Feb 22

It's a matter of timing. You can't populate a list  until it exists. You can't
guarantee that the list exists  before your Feature runs. The only way that I
know of to do this would be to create  a List Template Feature (not a List
Instance Feature) and instantiate that in the Configuration section. You can
populate it with entries at that point.

Answer #6    Answered By: Emily Clark     Answered On: Feb 22

but I was activating the feature  as part of my site  def, so
the list  did exist, which is why it failed to get created as part of
the configuration section. One thing to note here, is that my
feature is just a custom  web control and a standard Link list.

I changed my thinking on the custom web  contro and feature. I made
it so that the feature doesn't create  the list. Instead, the web
control itself checks to see if the list exists  (i.e. created in the
onet.xml file), and if it doesn't will create an empty  instance.

So, if someone wants it prepopulated as part of the onet.xml, they
create a standard link list (with the name that the control is
expecting) and populate it in the configuration section. If they
just want the list there to use later, they just need to activate the

Didn't find what you were looking for? Find more on Populating a list via Site Definition's onet.xml Or get search suggestion and latest updates.