2

i am trying to create calculated site column in sharepoint 2010 but as soon as i click on radio button of "calculated (calculation based on other column)" i get and error. i am following these steps.

1 >> goto "site settings"

2 >> click "site columns"

3 >> click "create"

4 >> write "MyTestColumn" in "column name"

5 >> select "calculated (calculation based on other column)" option

this is where i got an error. below i have mentioned error from log file. please note that i didn't press ok button. as soon as i select calculated option i get this error. also below error says that key "'Title_Title'" already added but trust me i didn't write this ('Title_Title') in column name.

please advice.


Error


09/15/2017 17:08:45.02 w3wp.exe (0x2574) 0x360C SharePoint Foundation Runtime tkau Unexpected System.ArgumentException: Item has already been added. Key in dictionary: 'Title_Title' Key being added: 'Title_Title' at System.Collections.SortedList.Add(Object key, Object value) at Microsoft.SharePoint.ApplicationPages.BasicFieldEditPage.WriteFieldNamesForFormulaColumnPicker(TextWriter output, SPFieldCollection fields, String currentDisplayName) at ASP._layouts_fldnew_aspx.__Render__control15(HtmlTextWriter __w, Control parameterContainer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.RenderChildren(HtmlTextWriter writer) at System.Web.UI.Page.Render(HtmlTextWriter writer) at Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.Render(HtmlTextWriter writer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 725f06d5-390f-486b-9c20-1424cba5feec

  • There is a fix for the issue in the article below. Run the code on a server with SharePoint. For more detailed information, refer to the article below. SharePoint – Item has already been added. Key in dictionary: ‘484’ Key being added: ‘484’. blogs.msdn.microsoft.com/timquin/2009/02/11/… – Amy_MSFT Sep 15 '17 at 8:48
1
+50

Assuming there is no Title_Title field exists in Site columns.

As this is an environment specific issue so not easy to reproduce and troubleshoot. Please follow these steps to troubleshoot yourself.

  1. Go to SharePoint server layouts folders normally at C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS and make a copy of file FldNew.aspx to FldNewTest.aspx.
  2. Open FldNewTest.aspx in a text editor and locate the method call WriteFieldNamesForFormulaColumnPicker(Response.Output, spFlds, strDisplayName); and comment it.
  3. Just below the commented method WriteFieldNamesForFormulaColumnPicker, add the below code. Now you need to troubleshoot here using console.log. See its example below.

    SortedList list = new SortedList(new Comparer(fields.Web.Locale), fields.Count);
    foreach (SPField field in fields)
    {
        if ((((!(field is SPFieldText) && !(field is SPFieldCalculated)) && (!(field is SPFieldNumber) && !(field is SPFieldDateTime))) && (!(field is SPFieldChoice) || (field is SPFieldWorkflowStatus))) && (!(field is SPFieldBoolean) || (field is SPFieldAllDayEvent)))
        {
            SPHttpUtility.NoEncode("<script>console.log('" + field.GetType().ToString() + " " + field.Title + "');</script>",  Response.Output);
            continue;
        }
        if (((field.InternalName != "_UIVersionString") && !field.Hidden) && (field.Title != strDisplayName))
        {
            //Error throws here   
            list.Add(field.Title + "_" + field.InternalName, field);
        }
    }
    bool flag = true;
    foreach (SPField field2 in list.Values)
    {
        string title = field2.Title;
        SPHttpUtility.NoEncode("<option value=\"[", Response.Output);
        SPHttpUtility.HtmlEncode(title, Response.Output);
        SPHttpUtility.NoEncode("]\"", Response.Output);
        if (flag)
        {
            SPHttpUtility.NoEncode(" selected=\"selected\"", Response.Output);
            flag = false;
        }
        SPHttpUtility.NoEncode(">", Response.Output);
        SPHttpUtility.HtmlEncode((title.Length > 20) ? (title.Substring(0, 20) + "...") : title, Response.Output);
        SPHttpUtility.NoEncode("</option>", Response.Output);
    }
    
0

thanks Ahmed Zia for your guidance. although it didn't work straight away but it helped alot. i replaced

WriteFieldNamesForFormulaColumnPicker(Response.Output, spFlds, strDisplayName);

with

TextWriter output =  Response.Output;
SPFieldCollection fields = spFlds;
string currentDisplayName = strDisplayName;

SortedList list = new SortedList(new Comparer(fields.Web.Locale), fields.Count);
foreach (SPField field in fields)
{
    if ((((!(field is SPFieldText) && !(field is SPFieldCalculated)) && (!(field is SPFieldNumber) && !(field is SPFieldDateTime))) && (!(field is SPFieldChoice) || (field is SPFieldWorkflowStatus))) && (!(field is SPFieldBoolean) || (field is SPFieldAllDayEvent)))
    {
        SPHttpUtility.NoEncode("<script>console.log('" + field.GetType().ToString() + " " + field.Title + "');</script>",  Response.Output);
        continue;
    }
    if (((field.InternalName != "_UIVersionString") && !field.Hidden) && (field.Title != strDisplayName))
    {
try
{
        list.Add(field.Title + "_" + field.InternalName, field);
}
catch
{

}
    }
}
bool flag = true;
foreach (SPField field2 in list.Values)
{
    string title = field2.Title;
    SPHttpUtility.NoEncode("<option value=\"[", Response.Output);
    SPHttpUtility.HtmlEncode(title, Response.Output);
    SPHttpUtility.NoEncode("]\"", Response.Output);
    if (flag)
    {
        SPHttpUtility.NoEncode(" selected=\"selected\"", Response.Output);
        flag = false;
    }
    SPHttpUtility.NoEncode(">", Response.Output);
    SPHttpUtility.HtmlEncode((title.Length > 20) ? (title.Substring(0, 20) + "...") : title, Response.Output);
    SPHttpUtility.NoEncode("</option>", Response.Output);
}

i also had to add below line at the top

<%@ Import Namespace="System.IO" %>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.