I need to populate a list that is created as part of a custom site definition from another source. Ive tried using a feature receiver but it states that the list has not been created. I guess that the featureactivated event is triggered before the list has been provisioned. How can i get custom code to run once the site creation has been fully completed.
You can add default data in the list instance itself.
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance Title="Equipment Availability"
OnQuickLaunch="TRUE"
TemplateType="10001"
Url="Lists/EquipmentAvailability-ListInstance1"
Description="My List Instance">
<Data>
<Rows>
<Row>
<Field Name ="Title">Projector</Field>
<Field Name ="EquipmentDescription">
High Definition Projector with built-in speaker.
</Field>
<Field Name ="EquipmentAvailable">TRUE</Field>
</Row>
<Row>
<Field Name ="Title">Wired Microphone</Field>
<Field Name ="EquipmentDescription">Dynamic Voice Microphone.
</Field>
<Field Name ="EquipmentAvailable">FALSE</Field>
</Row>
<Row>
<Field Name ="Title">Wireless Microphone System</Field>
<Field Name ="EquipmentDescription">
Two hand held microphones and VHF receiver system.
</Field>
<Field Name ="EquipmentAvailable">TRUE</Field>
</Row>
</Rows>
</Data>
</ListInstance>
</Elements>
If your List is provisioned via a feature, you can add data to the list instance check out this question it has a sample of what you might be looking for.
-
Im not sure this is going to work. The list is provisioned via a feature but it is used all over our farm. I only need to prepopulate the list when its used on this specific site definition – Richard Banks Mar 19 '13 at 16:07
-
Well you can try to do this: 1 - Create a feature with an instance of this list type 2 - This specific instance has the data you need. 3 - If you're working with site templates I suppose you know that you can define which features should be activated on the site creation. If you don't, let me know and I'll post an example of a site template I have. Cheers! – Jaime Mar 19 '13 at 16:15
The data loading should be in a feature. Use a WebTemplate to provision the site.
http://sharepointchick.com/archive/2010/06/15/site-definitions-vs.-webtemplates.aspx