Introduction
Over my years in SharePoint development I have had the following issue occur.a couple of times.
Actually back in July 2010, I posted a blog entry which solved a problem with the Manage Content and Structure page which was related to duplicate lists in a site.
- I create a custom List with a customised List Definition which uses a schema.xml to define the List Template
- I create a Feature which uses the customised List Definition to create a new List Template with the <ListTemplate> feature element.
- I configure the feature to create an Instance of the list using the <ListInstance> feature Xml element,
- Activate the feature in a SharePoint Web, click Site Actions->View All Site Content.
- Two instances of the list appear in the View All Content page, both reference the same SharePoint list.
- Figure below shows an example of two duplicate lists in the web.
I have then always wondered what causes this?
What is interesting is that one link points to one view and the other link points to a different view, this hint was the lead to help solve the issue.
Solution
I started the investigation by digging into the SharePoint databases now quick warning, “you should not read or edit the database, doing so will leave your SharePoint installation unsupported by Microsoft!”
However, I was very careful and did not make any changes to the database.
It was one of the tables that lead me to working out why I was having these duplicate links. This table was the BuildDependencies table. I performed a
SELECT TOP 1000 [SiteId]
,[DirName]
,[LeafName]
,[TargetDirName]
,[TargetLeafName]
,[DirectDependency]
,[DeleteTransactionId]
FROM [BuildDependencies]
Where [DirName] LIKE ‘sites/sitename%’
Looking through the results I could see that the list had two views one called ‘ByFeatures.asppx and the other ‘AllItems.aspx’
This was correct my List Schema had defined these two views and then it dawned on me, what if SharePoint is looking at the schema.xml to work out which list page to display in the View All Content page.
So I went into my schema.xml and low and behold there was an attribute on the <View> element called DefaultView. Now both the AllItems.aspx and ByFeatures.aspx had this set to TRUE.
Eureka!
So to fix this I followed this process:-
- Updated the schema.xml <View/> element for the AllItems.aspx view
- Modified the DefaultView attribute and set it to FALSE
- Redeployed the solution
- Perform an IISRESET
- Deactivate the Feature
- Delete the list
- Activate the Feature to create the list
Now I only see one instance of the list in the View All Content page.
However, there is a problem with this approach and that is you lose the data in the list!
To Fix Existing Lists with No data loss
So we need a way to fix the lists that have already been created, seeing as the existing lists are not fixed by the schema changes then these properties must have been copied into the content database.
So to fix existing lists do the following:-
- Browse to the list and open up the List Settings page using the Ribbon
- Create a new View call it what you want, make sure you set it to default
- This will reset the Default View attribute on the other views and make the new view the default view.
- Modify the view that should really be the default view and tick the make default view checkbox. (This doesnt appear if you have multiple views with the default view set).
- Update the view
- Delete any views that are not needed
You should now see only one list instance in the View All Site Content page!
Hey mate, thanks for this informative article. It saved my ()() today.
Glad to help!
Cheers
Simon
Hi Simon, love your blog, sounds so exciting, i\’m really envious. You get to think about Azure Sharepoint while i’m stuck travelling the world. Mwah ha ha ha. Love Ben xxxx Nick says “just out of interest, is it possible to connect sharepoint API using PHP or does that not support NTLM?
Haha – well no I don’t believe that PHP can talk to SharePoint API on premise but it will be able to talk to SharePoint in the cloud as that uses a different authentication mechanism based on OAuth and adding HTTP Header tokens.