Chris Farmer
Chris Farmer

Reputation: 25396

How did I get multiple lists with the same name in my SharePoint site?

I have a SharePoint site that's being created from a custom site definition. The site definition has the following Features:

  1. A custom content type.
  2. A custom list template whose schema.xml file refers to that content type.
  3. A list instance feature which refers to my above list template feature.

During the site provisioning process, I activate each of these features (each is at the SPWeb level) through C# code in the order above. My resulting site looks as I expect and seems to work fine, but it has the weird artifact that the "all site content" page for my site shows my custom list twice.

My list acts okay -- its item receivers fire correctly and only once. In SharePoint Manager (SPM), I also see the list show up twice, and when I expand the tree to look at the attributes, they appear identical across the two lists (even the list items inside the lists). I suspect that I may be fooling myself and SPM might be just looking at the same list twice, while some actual rogue list lies in the dark shadows of my site.

So, what could have gone wrong here? How could I have created multiple lists of the same name? How can I correctly create this list? And how can I properly clean up the weirdness in existing sites that exhibit this behavior?


Edit: In response to Michael Stum's question, I created this console app to loop through the site's lists and get the ID:

using (SPSite site = new SPSite("http://myserver/projects/myproject"))
{
    using (SPWeb web = site.OpenWeb())
    {
        var lists = web.Lists;
        foreach (SPList list in lists)
        {
            Console.WriteLine(list.ID + ": " + list.Title);
        }
    }
}

This code shows my list twice -- same title, same ID.


Another edit: I looked in the SharePoint content database for this site, and I executed this query:

SELECT * FROM AllLists where tp_webid = '<my SPWeb guid>'

This reveals that there's only one actual list with the title and GUID that I retrieved from my C# code above. So what is causing these multiple entries to show up when I'm browsing through my site?

Upvotes: 2

Views: 4485

Answers (5)

Brian P
Brian P

Reputation: 43

Groenewegen is spot on.

I ended up with two Announcements lists on a site after I ran Export-SPWeb on a subsite and then Import-SPWeb to move it to a new site collection.

To fix it, I created a new default view for the list, All List Items, selected one of the two All Items views and deleted it, and the issue was fixed.

The Announcements list was being displayed twice on the View All Site Content page, and the data was being shown twice when viewing the All Items page.

Also, an intermediate step that you have to take before creating a new default view, is to open the list or library and add "?contents=1" to the URL so you can open the web part maintenance page and "Close" one of the duplicates. You have to do this because the web part ribbon will not show up on the Announcements page if multiple web parts exist, and you need the ribbon to access the view drop down and create a new view.

Upvotes: 1

Groenewegen
Groenewegen

Reputation: 11

Today I came across this issue and after reading the above answers I came up with an easy solution. Just create a new Default view and the Document library will show up normally again.

Kind regards,

Thijmen Groenewegen

P.s

I "created" the same two libraries by migrating the library from one place to another. At the old place the library was only showed once. If I look at the default views on that library two views are checked as Default.

Upvotes: 1

Ramon Br&#252;lisauer
Ramon Br&#252;lisauer

Reputation: 31

I've come across with this issue several times. It's not a bug, most likely you have semantic errors in the elements.xml of your list template.

If a list definition contains more than one default view, the symptoms you described above will show up. Check the elements.xml file of your list template and make sure you don't have more than one View-Element with in it.

Kind regards Ramon

Upvotes: 3

Colin
Colin

Reputation: 10638

I suggest you put a call in to Microsoft, this sounds like a bug.

P.S. without seeing the actual solution that creates the list we can't determine what's happening, perhaps a feature got activated twice...

Upvotes: 1

Johan Leino
Johan Leino

Reputation: 3533

Have you tried with:

list.RootFolder.Name

(which shows the "internal" name - a part of the url)

list.Title shows the displayname (which can appear twice or more).

This could also be the explanation why you get multiple lists. You have maybe added them with the same displayname but dirrerent "internal" names?

Upvotes: 0

Related Questions