David Jacobus

SharePoint Consultant

  Home  |   Contact  |   Syndication    |   Login
  17 Posts | 0 Stories | 7 Comments | 0 Trackbacks

News

Hello,
My name is David Jacobus I am a former teacher of Computer Science and Mathematics, who is now working full time as a SharePoint Consultant!

Article Categories

Archives

Post Categories

List Instance Woe’s

My last SharePoint Project had at least 20 custom list instances which were a pain point for a couple of us developers! There are a couple of ways to create custom list instances. Our Way:

1. We tied all of our lists to custom content types.

2. We created the custom fields and content types in code as feature receivers.

3. We created the custom list in the UI .

a. Added the content type

b. Modified the default view with the custom fields.

4. We then exported the site as a WSP and then imported the WSP into Visual Studio for one or more lists.

a. This gave us the Schema.xml

b. Pages module

i. This was the main cause of our problems!

ii. Here is an example for a navigation list

clip_image002

5. This would equate to two features the list instance feature and the pages feature

a. The pages module would be the NewForm, DisplayFormand EditForm forms.

6. On the last list instance of the Project, I figured out that in reality we didn’t need the Pages module at all! We just needed to change a couple of lines in the schema.xml file. (Who knew! As that file is a monstrosity!) I am making the assumption that you would need this module if you had some customization of the NewForm, DisplayForm and EditForm pages.

a. Here is all that needed to be changed in the schema.xml:

From:

<Forms />

To:

<Forms>

<Form Type="DisplayForm" Url="DispForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />

<Form Type="EditForm" Url="EditForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />

<Form Type="NewForm" Url="NewForm.aspx" SetupPath="pages\form.aspx" WebPartZoneID="Main" />

</Forms>

7. I have since found an even sweeter way to do this whole process that is repeatable and will make our lives as developers much easier!

8. I found and Visual Studio Extension project on CodeProject that makes the third step in creating list instances trivial!

http://www.codeproject.com/KB/sharepoint/ImportList.aspx

Kudo’s to: Mark Nischalke

9. So the steps are:

a. Create the Content Type and Site Columns in Code (push to the site)

b. Create the List in the UI (adding Content type and changing the default view).

c. Import the List Instance into the project with the List Import Command on the Add new Item menu.

posted on Tuesday, September 20, 2011 4:21 AM