Archive for January, 2017

Finding a Needle in a Haystack SharePoint Style: Search Concepts and Content Quality

After a couple of trial runs with our previous SharePoint Search presentation, Joanne Klein and I decided we really needed to trim it down.  As it was, we were able to create two separate presentations from our single initial presentation.  On January, 25, 2017 we presented the first in our new series based on that initial presentation: Finding a Needle in a Haystack SharePoint Style: Search Concepts and Content Quality.  The presentation was hosted by the Saskatchewan SharePoint O365 User Group and had a great turnout and great interaction with Joanne and myself.

Both Joanne and I always want to ensure that our slides are available to all even if you couldn’t attend so we have uploaded them for others to view.  You can access the slides here.

 

Thanks for reading!!

Unable to Add Existing Site Columns to Content Types in SharePoint

While deploying a new solution to our test environment for my client the other day I found that I was unable to add existing site columns to content types within the SharePoint site I was working in.  No real reason given.  As you can see from the screenshot below the GUI wasn’t much help:

Unable to Add Existing Site Columns to Content Type - GUI Error

However, as always SharePoint provided the handy-dandy correlation id.  Using that I was able to get a great deal more information on the problem.

01/03/2017 13:18:07.08 	w3wp.exe (ServerName:0x087C)         	0x2D4C	SharePoint Foundation         	General                       	8nca	Medium	Application error when access /_layouts/15/fldpick.aspx, Error=No two choices should have the same ID   at Microsoft.SharePoint.ApplicationPages.ChoiceComparerWithDefaultGroup.Compare(PickerItem c1, PickerItem c2)     at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit)     at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit)     at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit)     at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 de...	137fc79d-a097-403e-4c78-ff67da2e62e2
01/03/2017 13:18:07.08*	w3wp.exe (ServerName:0x087C)         	0x2D4C	SharePoint Foundation         	General                       	8nca	Medium	...pthLimit)     at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer)	137fc79d-a097-403e-4c78-ff67da2e62e2
01/03/2017 13:18:07.08 	w3wp.exe (ServerName:0x087C)         	0x2D4C	SharePoint Foundation         	Runtime                       	tkau	Unexpected	System.ArgumentException: No two choices should have the same ID    at Microsoft.SharePoint.ApplicationPages.ChoiceComparerWithDefaultGroup.Compare(PickerItem c1, PickerItem c2)     at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit)     at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit)     at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit)     at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit)     at System.Collections....	137fc79d-a097-403e-4c78-ff67da2e62e2
01/03/2017 13:18:07.08*	w3wp.exe (ServerName:0x087C)         	0x2D4C	SharePoint Foundation         	Runtime                       	tkau	Unexpected	...Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer)	137fc79d-a097-403e-4c78-ff67da2e62e2
01/03/2017 13:18:07.08 	w3wp.exe (ServerName:0x087C)         	0x2D4C	SharePoint Foundation         	General                       	ajlz0	High	Getting Error Message for Exception System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: Failed to compare two elements in the array. ---> System.ArgumentException: No two choices should have the same ID     at Microsoft.SharePoint.ApplicationPages.ChoiceComparerWithDefaultGroup.Compare(PickerItem c1, PickerItem c2)     at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit)     at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit)     at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, ...	137fc79d-a097-403e-4c78-ff67da2e62e2
01/03/2017 13:18:07.08*	w3wp.exe (ServerName:0x087C)         	0x2D4C	SharePoint Foundation         	General                       	ajlz0	High	...Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit)     at System.Collections.Generic.ArraySortHelper`1.DepthLimitedQuickSort(T[] keys, Int32 left, Int32 right, IComparer`1 comparer, Int32 depthLimit)     at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer)     --- End of inner exception stack trace ---     at System.Collections.Generic.ArraySortHelper`1.Sort(T[] keys, Int32 index, Int32 length, IComparer`1 comparer)     at System.Collections.Generic.List`1.Sort(Int32 index, Int32 count, IComparer`1 comparer)     at Microsoft.SharePoint.WebControls.GroupedItemPicker.GetDataString(StringBuilder sb)     at Microsoft.SharePoint.WebControls.GroupedItemPicker.Render(HtmlTextWriter writer)     at System.Web.UI.Control.Render...	137fc79d-a097-403e-4c78-ff67da2e62e2
01/03/2017 13:18:07.08*	w3wp.exe (ServerName:0x087C)         	0x2D4C	SharePoint Foundation         	General                       	ajlz0	High	...ControlInternal(HtmlTextWriter writer, ControlAdapter adapter)     at ASP._layouts_15_fldpick_aspx.__Render__control16(HtmlTextWriter __w, Control parameterContainer)     at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)     at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)     at ASP._controltemplates_15_inputformsection_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer)     at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)     at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)     at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)     at System.Web.UI.Cont...	137fc79d-a097-403e-4c78-ff67da2e62e2
01/03/2017 13:18:07.08*	w3wp.exe (ServerName:0x087C)         	0x2D4C	SharePoint Foundation         	General                       	ajlz0	High	...rol.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)     at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)     at Microsoft.SharePoint.WebControls.AjaxDelta.RenderChildren(HtmlTextWriter output)     at System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer)     at System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)     at Microsoft.SharePoint.WebControls.AjaxDelta.Render(HtmlTextWriter writer)     at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)     at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)     at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)     at System.Web.UI.HtmlContr...	137fc79d-a097-403e-4c78-ff67da2e62e2
01/03/2017 13:18:07.08*	w3wp.exe (ServerName:0x087C)         	0x2D4C	SharePoint Foundation         	General                       	ajlz0	High	...ols.HtmlContainerControl.Render(HtmlTextWriter writer)     at Microsoft.SharePoint.WebControls.SharePointForm.Render(HtmlTextWriter output)     at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)     at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)     at System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)     at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)     at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)     at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)     at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection ...	137fc79d-a097-403e-4c78-ff67da2e62e2
01/03/2017 13:18:07.08*	w3wp.exe (ServerName:0x087C)         	0x2D4C	SharePoint Foundation         	General                       	ajlz0	High	...children)     at Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.RenderChildren(HtmlTextWriter writer)     at System.Web.UI.Page.Render(HtmlTextWriter writer)     at Microsoft.SharePoint.WebControls.DeltaPage.RenderToBase(HtmlTextWriter writer)     at Microsoft.SharePoint.WebControls.DeltaPage.Render(HtmlTextWriter writer)     at Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.Render(HtmlTextWriter writer)     at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.HandleError(Exception e)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean include...	137fc79d-a097-403e-4c78-ff67da2e62e2
01/03/2017 13:18:07.08*	w3wp.exe (ServerName:0x087C)         	0x2D4C	SharePoint Foundation         	General                       	ajlz0	High	...StagesAfterAsyncPoint)     at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)     at System.Web.UI.Page.ProcessRequest()     at System.Web.UI.Page.ProcessRequest(HttpContext context)     at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()     at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)	137fc79d-a097-403e-4c78-ff67da2e62e2

Specifically, the problem was: “No two choices should have the same ID“.  Looking at the stack trace you can see that it looks like SharePoint is looking at the fields that exist in the site.  This makes sense because it has to build that list for you to choose from doesn’t it?  I scanned through my list of site columns and noticed that for some reason I had two columns called “Hashtags”.  I am not entirely sure what this field is for, but I believe it is added with the Newsfeed.

Unable to Add Existing Site Columns to Content Type - Multiple Hashtags

So the next step?  Well let’s delete the extra column.  Attempting to delete via the GUI just resulted in a window that never provided a response, nor deleted the offending field.  Next onto PowerShell.  While getting the field object I found that the two fields actually existed with the exact same GUID.  So that’s where the error message above came from.  While deleting via PowerShell I got a bit further and received the message: “Site columns which are included in content types cannot be deleted“.   I didn’t have a content type sitting there with Hashtags within it, so ran a script to go through each content type and to look for the field.

There were two hidden, system content types Project Policy and System Media Collection that contained the site column.  I did a few things to try and remove the site column from the content types, but I am not going to outline here because I don’t want to give any of you ideas (they aren’t something you want to do in a production environment and they didn’t work anyways).  Needless to say, I did everything I could think of but I could not remove the extra field from the sites.

Placed a call with Microsoft to see if they had any suggestions.  Apparently, according to the support engineer I worked with, Microsoft has seen this before.  Nowhere in the vast interwebs did I find this information.  One reason for this post is for prosperity ;-).  The fix is actually really simple.

Removing the Extra Field

Microsoft provided me with the feature definition of the Hashtags field.  The solution was to install the feature into the farm, activate the feature on the sub sites that had the Hashtags field existing within (whether they had the double instance or not) and then disabling the feature within the site.  Finally, we removed the feature from the farm as well.  I will provide that feature definition in this post, but want to make something very clear.  I did not create this, nor do I provide any warranty or take any responsibility if applying the solution causes instability in your farm.

You can download the feature here.

To apply the feature to correct your farm, follow these steps.

  1. Extract the zip file and place the MMSField folder in the directory: C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\TEMPLATE\FEATURES.
  2. Open a SharePoint PowerShell window and run the following command:
Install-spfeature -path MMSField
  1. After the feature is added to the farm run the following script to check each sub site within your site collection to add and remove the feature (this step will force the system to remove the field and re-add it properly).
$spSite = Get-SPSite <URL>

foreach ( $spWeb in $spSite.AllWebs)
{
    $spField = $spWeb.Fields['HashTags']
    if ( $spField -ne $null )
    {
        Write-host $spWeb.url, $spField.Title
        Enable-SPFeature -Identity MMSField -Url $spWeb.url -Force -Confirm:$false
        Disable-SPFeature -Identity MMSField -Url $spWeb.url -Force -Confirm:$false
    }
}
  1. Remove the solution from the farm by running the following command:
Uninstall-spfeature -identity MMSField

Once this is complete you will have removed the extra instances of the HashTags field and can now add site columns to your content types without issues.

 

Thanks for reading!