Tuesday, February 03, 2009

My daily SharePoint frustration - XVII

Problem: You cannot add data to a list though a site definition ( ONET.XML ) for a list instance created by a Feature. In a site definition you may instantiate a list and add data (rows) to it by using the Lists/List elements, but it will always be brand new list instances. There is no way to reference a list instance created by the Feature and just add rows to that list.

Solution: none.

Workaround: Set the list in ONET.XML to be a 'temporary list'. Have the Feature to also declare a (main) list instance. Both lists are of the same type. Upon site creation, have code to copy over the data from the temporary list to the main one, and delete the temporary list.

No comments: