Monday, August 13, 2012

How To Fix A duplicate field name “X” was found Error

Problem

If you’ve arrived at my blog with this error then I apologize, you’ve got a tough road ahead of you, there’s no easy fix to this dreaded “A duplicate field name ‘’ was found” error in SharePoint 2010. 
More than likely you’re trying to create a site from a template but you keep getting the “A duplicate field name “ x” was found”.  You’ve tried everything, including deleting the old site template, deleting the field in question from the site and the site collection, and you’ve probably even tried to download and modify the template wsp itself but then you can’t makecab it.

clip_image001

Explanation

I’m not to sure what causes this issue to arise, I’ve come across it about 5 times now and in the case below, where I simply had to fix it, was the first time I attempted to resolve the issue.  My theory is that the error arises when the content type syndication hub delivers a content type and its corresponding fields to a site that was created from a backup on another site collection that already had the content type.  Now that just a a guess and I’m sure you’re more interested in the solution.

You can see the error by renaming the WSP to .CAB

clip_image002
clip_image003

The place where the duplicates exist is the ElementsFields.xml

clip_image004

Here’s my duplicate field, note how the field is listed twice

clip_image005

Solution 1

Delete and rebuild the site from the bottom up.  Sometimes, when dealing with SharePoint, it’s easier to build SharePoint sites from the bottom up as opposed to repairing broken, corrupt, or damaged sites. 

Solution 2

So this solution is not for the weary, it involves downloading the site template and repairing it using Visual Studio.  The first thing you’ll need is a copy of Visual Studio 2010 Professional or greater installed on a SharePoint Server (DO NOT INSTALL ON YOUR PRODUCTION SHAREPOINT SERVER!!!).  With Visual Studio 2010 Professional there’s an import function that will allow you to download a SharePoint site
Download the WSP from the Solutions gallery (in my case it’s located at http://sharepoint/_catalogs/solutions/Forms/AllItems.aspx )

clip_image002

Open Visual Studio and choose the project type “Import SharePoint Solution Package”. 
If you do not see this option then you didn’t read my previous notes that you must install Visual Studio 2010 Professional or greater.

clip_image007

Specify the solution

clip_image008

Allow all items to be imported

clip_image009

The import may take a while

clip_image010
clip_image011

In the solution explorer locate the Elements.xml file

clip_image012

Remove the duplicate field

clip_image013

On the build menu choose “Package”

clip_image014

You may receive a file length error, in my case I had to remove a few files that I included with the solution because I checked the box to include data

clip_image015

If you saved the site as a template and included content, typically the names of the files that are exported will be too long, remove the files and try again. Note that you can remove the files from within Visual Studio. In the screenshot below I cleared all files that were moved with the site.  You will obviously have to re-upload this data when the template is re-created but it certainly does not affect the functionality of the site since it is just data, not settings or configuration.

clip_image016

Locate the newly compiles WSP in the Visual Studio 2010 projects folder in the bin/release or bin/debug directory for your solution (Usually it’s c:\users\username\Documents\Visual Studio 2010\Projects)

Source: http://www.sharepointassist.com/2011/11/05/a-duplicate-field-name-x-was-found/ 

1 comment:

  1. đồng tâm
    game mu
    cho thuê nhà trọ
    cho thuê phòng trọ
    nhac san cuc manh
    số điện thoại tư vấn pháp luật miễn phí
    văn phòng luật
    tổng đài tư vấn pháp luật
    dịch vụ thành lập công ty trọn gói
    nước cờ trên bàn thương lượng
    mbp
    erg
    nghịch lý
    chi square test
    nghệ thuật nói chuyện
    coase
    thuyết kỳ vọng
    chiến thắng con quỷ trong bạn
    cân bằng nash

    Chẳng qua Đảng ủy xã không nghĩ như vậy. Theo bọn họ thấy nếu xã có thể thu hút một hai công ty sẽ giảm được gánh nặng tài chính cho xã. Chẳng qua Lĩnh Đông ở tít trong núi, lại không có tài nguyên gì thì đâu có dễ.
    Triệu Quốc Đống suy nghĩ một chút rồi vứt mấy việc này ra khỏi đầu. Hắn ngồi dọc quyển sách mới mua. Nếu muốn tới Sở Giao thông công tác, mặc dù Thái Chánh Dương biết hắn chưa từng làm trong lĩnh vực này nên cũng sẽ lo lắng, nhưng Triệu Quốc Đống cũng không muốn mình là người mù, không biết gì cả. Cho nên hắn cũng cần học về nghiệp vụ giao thông.
    Triệu Quốc Đống vừa xem được vài trang thì nghe thấy Chánh văn phòng Ủy ban gọi vọng vào:
    - Bí thư Triệu, đi họp.
    Triệu Quốc Đống thở dài một tiếng gập sách, chỉnh quần áo rồi đi ra ngoài.

    Phòng hội nghị được bố trí theo hình trứng. Bí thư đảng ủy ngồi giữa, chủ tịch xã hơi lệch một chút, mấy Phó bí thư, Ủy viên Đảng ủy ngồi ở hai bên, rất có quy củ.

    Nội dung hội nghị cũng không nhiều, theo thường lệ đầu tiên học tinh thần của cấp trên, sau đó nghiên cứu vấn đề. Theo Triệu Quốc Đống thấy mình và mấy vị khác chỉ là ngồi cho có. Bí thư và chủ tịch xã nghiên cứu trước, đưa ra đây để cho đúng quy định mà thôi.

    Hắn cố nhịn không ngáp, đầu quay sang bên để giảm cơn buồn ngủ. Nhưng hắn vừa lúc nhìn thấy Tiểu Lâm – sinh viên mới ra trường được phân tới đang cầm một tập văn bản vào. Thấy mặt Triệu Quốc Đống nhăn nhó, người này không nhịn được mà cười.

    Bí thư đảng ủy Hà Chí Xương đang nói một tràng dài về tăng cường ý thức học tập của lãnh đạo thì bị tiếng cười của cô gái này làm cho mất hết hứng thú. Y trừng mắt nhìn đối phương làm Tiểu Lâm đỏ mặt mới lạnh lùng nói:
    - Tiểu Lâm, cô làm gì vậy hả? Đây là hội nghị Đảng ủy mà cô cũng cười được sao?

    Triệu Quốc Đống nhìn quanh một vòng. Hà Chí Xương này không có uy tín lớn, nhưng lại thích ra vẻ. Cũng may chủ tịch xã lại là người mềm yếu, còn là người từ ngoài đến nên Hà Chí Xương vẫn bình yên.

    - Bí thư Hà, sắp năm giờ rồi, chúng tôi còn phải bắt kịp chuyến xe cuối cùng, có thể mời chủ tịch Thôi nói công việc cụ thể không. Đợi tuần sau lại nghiên cứu vấn đề tồn tại trong tư tưởng của chúng ta.

    ReplyDelete