Table of Content Web Part: Slightly different in SharePoint 2013 / Online

The Table of Contents web part has been part of SharePoint’s make-up for a while now. It is useful function that is normally used to display a sitemap or to provide navigation for a sub site.

The Table of Contents Web Part has three main sections in the configuration pane:

  1. Content: This is where you configure what part of site hierarchy the Web Part displays. Enter the path to the page where you want to Table of Contents to begin in the Start From field. You can choose how many levels to display in the Table of Contents by using the Levels to Show drop-down list
  2. Presentation: This section controls how the items display. You can choose to display everything in a single column or multiple columns and select how the header is styled by selecting an option from the Header Style drop-down list
  3. Organization: Decide how you want the items sorted by selecting either the Sort Contents as They Are Sorted in Navigation or the Sort Contents Using the Following Settings radio button. If you choose the latter option, select applicable options from the Sort Sites By, Sort Pages By, and Sort Direction drop-down lists

For the most part, this functionality has remained exactly the same throughout the versions. However looking at the configuration options in SharePoint 2013 reveals one slight omission: the Display Columns setting.

This setting allowed you to specify the number of columns that the content was displayed in. However, in SharePoint 2013 / SharePoint online, the default column number is one. What this can potentially result in is a web part that displays its content in a very elongated, vertical manner.

To get around this, you can use the linked PowerShell Script to set the display column count. Please note that 7 is the maximum column count that you can use.

The variables that you will need to amend are: –

  • $web: Set this to the site level with the Table of Contents Web Part
  • $pages: Set the page name here that has the Table of Contents Web Part

Please note that the page itself must be checked in and published.

The script can be downloaded from the TechNet Gallery here.


Removing old workflow instances with Powershell

As most of you will know, there are two basic types of workflow in SharePoint. Some workflows are authored in SharePoint Designer whilst others are created within Visual Studio. This article is aimed at those who author workflows in SPD.

Each time a new workflow is published within SPD, a new instance is added. What this means is that each time a workflow is published, it overwrites a previous version. If an administrator were to check the active workflows, they’d see a history that looks like this

I don’t believe that there is any performance overhead for having these historical workflows listed but wouldn’t it be nice to have a way to remove these. This article is going to show you how.

  1. Download this PowerShell Script from the TechNet Gallery. Download it somewhere that is easy to find, such as C:/Scripts
  2. Right Click on the script and select Open
  3. Look for the following variables and change them as requird
    1. $web: Include the URL of your Site
    2. $listToCancel: Use the display name of the list / library that has the workflow versions you want to delete
    3. $wfToKeep: Use the name of the Workflow to be pruned
  4. Save and close the script
  5. Right click and select Run with PowerShell. Click Yes to the script. You’ll see this as the script has been downloaded from TechNet rather than written locally

  1. Once the script has run, return to your workflow history page. You should see only one version of the workflow as below


Please be mindful of any workflow instances that may still be in operation. The script won’t be too choosy in what it removes.


Thanks to Matthew Yarlett for looking over this script for me.

SharePoint 2010 Data Type Errors

So, having being tasked with creating a good deal of Content Types recently, I thought I’d be clever and write some PowerShell Scripts to do them for me.

Everything was going well until I ran a script that had an incorrect Field Type specified. Or, more accurately I made a typo when specifying a DateTime column. The Field Type is the Column type that you get to choose when creating a new column. I didn’t spot the problem until I tried checking on the outcome via Galleries à Site Columns and saw this error: –

I traced the log message down, which provided the following information: –

“Microsoft.SharePoint.SPException: Field type Date is not installed properly. Go to the list settings page to delete this field. at Microsoft.SharePoint.SPFieldCollection.CreateSPFieldFromSafeArray(Int32 index) at Microsoft.SharePoint.SPFieldCollection.CreateSPField(Int32 ifld) at Microsoft.SharePoint.SPFieldCollection.EnsureSPField(Int32 index) at Microsoft.SharePoint.SPFieldCollection.ItemAtIndex(Int32 iIndex) at Microsoft.SharePoint.ApplicationPages.FieldListRenderer.OnPreRender(EventArgs e) at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveInternal() at System.Web.UI.Control.PreRenderRecursiveIn… ”

As my errant column wasn’t yet attached to a list, I wasn’t able to log into any list settings to delete the column. My next port of call was SPD. However, upon trying this, I was hit with the following error: –

Not being able to get anywhere via the GUI, I thought I’d take a look at the Hive\14 files where SharePoint stores its Field Types. The SharePoint field times will typically be stored in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\XML\fldtypes.xml

Looking here, the definition for DateTime looked intact. For reference, the DateTime definition starts on line 346.

This meant that having made the error via scripting, I should be able to fix it via scripting. I’ll post back here if I work it out!