Sharepoint - the field appears twice in the view / new item

I have a problem in the SharePoint list - some fields appear twice in the "Screen", "New item" form and on the list settings page. Both fields have the same identifier and the same property page (the same URL), so hiding one hides the other.
Using SharePoint Manager I can only see one field, but maybe I looked at the wrong places? Has anyone experienced something similar, and how can I solve this problem?

+5
source share
5 answers

It is not recommended to update the xml that creates the content type. If you want to add fields later to the content type, execute it using the new function, see this link.

MSDN Article

Pay attention to the following text.

Under no circumstances should you update the content type definition file for the content type after you have installed and activated this content type. Windows SharePoint Services does not track changes made to the content type definition file. Thus, you have no way to flush changes made to site content types to child content types. For best practices for making changes to the content types that have been installed and activated, see the "Upgrading Content Types" section.

+4
source

, , /edit/view . , .

+7

Yepp, , . - -, . , , id .

, ( , ), XML (), . ... .

+5

powershell script dublicates:

Clear-Host
Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") 

$web=Get-SPWeb "http://weburl.here"

function cleanFieldLinks($listName){
    $list = $web.GetList($listName)
    $ct = $list.ContentTypes[0];

    $flDub = $ct.FieldLinks | group-object DisplayName | where { $_.Count -gt 1 }

    foreach($fl in $flDub)  {
        $skipFirst = $fl.Group | select-object -skip 1

        foreach($flDel in $skipFirst){
            $ct.FieldLinks.Delete($flDel.Id)
        }
    }   
    $ct.Update()

}

cleanFieldLinks("lists/listurl")
$web.Dispose()
+2

1) -, , , , MOSS 2007 MOSS 2013. MOSS 2013, , . , , , MOSS 2013, , .

2) . , , .

3) I wrote a web forms page to solve the problem with the appearance of the field several times in view, new and edit forms. You just need to change the code to indicate the list you want to check. This version will remove the first instance of fieldref and save the second instance:

using System;
using System.Collections;
using System.Configuration;
using System.Data;
//using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
//using System.Xml.Linq;

using Microsoft.SharePoint;

using System.Text;
using System.Collections.Generic;



public partial class FixDuplicateFieldIssue : Microsoft.SharePoint.WebControls.LayoutsPageBase
{



    protected void Page_Load(object sender, EventArgs e)
    {
        if (SPContext.Current.Web.CurrentUser == null)
        {
            Response.Write("You must be logged in to view this page.");
            Response.End();
            return;

        }
        if (!SPContext.Current.Web.DoesUserHavePermissions(SPBasePermissions.ManageWeb))
        {
            Response.Write("You do not have permissions to view this page.");
            Response.End();
            return;
        }

        lblOutput.Text = "";

        StringBuilder sbOutput = new StringBuilder();

        using (SPSite site = new SPSite(SPContext.Current.Site.ID))
        {
            using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
            {
                try
                {    
                    hlBack.NavigateUrl = web.Url;

                    //open the List  **** SPECIFY THE LISTNAME HERE ***
                    SPList spList = web.Lists["LISTNAME"];
                    if (spList != null)
                    {
                        //Check FieldLinks

                        sbOutput.Append("<table border='1'>");

                        foreach (SPContentType ct in spList.ContentTypes)
                        {
                            sbOutput.Append("<tr>");
                            sbOutput.Append("<td>" + ct.Name + "</td>");
                            sbOutput.Append("<td>");

                            Dictionary<string, Guid> GuidDictionary = new Dictionary<String, Guid>();   
                            List<Guid> RepeatList = new List<Guid>();
                            //SEARCH THE CONTENT TYPE FOR REPEAT SPFieldLinks
                            foreach (SPFieldLink spfl in ct.FieldLinks)
                            {
                                if (!GuidDictionary.ContainsKey(spfl.Name.ToLower()))
                                {
                                    GuidDictionary.Add(spfl.Name.ToLower(), spfl.Id);
                                }
                                else if (GuidDictionary[spfl.Name.ToLower()].ToString().ToLower()!=spfl.Id.ToString().ToLower())
                                {
                                    //Record the GUID of the repeat SPFieldLink you want to delete in the RepeatList.  In this case, we're recording the first item.  If you want to delete the second one, add the spfl.Id instead.
                                    RepeatList.Add(GuidDictionary[spfl.Name.ToLower()]);
                                    sbOutput.Append("<span style='color:red;'>*</span>");
                                }

                                sbOutput.Append(spfl.Name +  "," + spfl.Id + "," + spfl.DisplayName +"<br />");

                            }
                            sbOutput.Append("</td>");

                            sbOutput.Append("<td>");
                            sbOutput.Append("Repeats found: " + RepeatList.Count + "<br />");

                            //DELETE THE Repeat Field Links
                            foreach (Guid idToDelete in RepeatList)
                            {

                                sbOutput.Append("Deleting FieldRef with ID= " + idToDelete.ToString() + "<br />");
                                web.AllowUnsafeUpdates = true;
                                ct.FieldLinks.Delete(idToDelete);
                                ct.Update();
                                web.AllowUnsafeUpdates = false;

                            }
                            sbOutput.Append("</td>");




                            sbOutput.Append("</tr>");
                        }
                        sbOutput.Append("</table>");





                    }
                }
                catch (Exception ex)
                {
                    sbOutput.Append("Error Occurred: " + ex.ToString());
                }

            }
        }
        lblOutput.Text = sbOutput.ToString();

    }
}
+2
source

All Articles