List Template Duplicate Field


Many of us have saved custom lists as templates in SharePoint Online or on-premises, to be re-purposed in the future, as an easy way to re-create the same list, with the same content types, metadata and structure. This is a an easy way for developers to give the end user a prepackaged custom list, rather than developing a provisioning tool to create a unique list. This added benefit to this method is the ability to allow the end-user to quickly create their own list based on a specific template, without the need to ask IT to do it for them.

In some rare cases, if you are trying to created a list from a custom list template, you may end up getting an error of a duplicate field name. The exact error will be "A duplicate field name was found". The list template has been created in the same site collection and you cannot find why and where is the other duplicate field name.
 

Cause

There are 2 possible causes to your issue:

  1. Your list template is referencing the same field twice
  2. Your list template is referencing a field tat already exist in the site collection but with a different GUID

Resolution

In my case, the second cause was my issue. The resolution for both issues is similar. Here are the steps:

Step 1 – Editing your template

  1. Save your template.tsp to your desktop
  2. Rename your template.tsp to template.cab
  3. Extract your template.cab to a specific location
  4. Edit the manifest.xml
  5. Look for the duplicate field name and delete the node.

This will do it for there are 2 nodes for the same field name. If this is not the case, then the GUID is your issue, and you will need to change the GUID in your template with the right GUID from your site collection. Remember that when you create a list from a custom template, if the any column already exist in the site collection, the GUID of the list template must match the GUID of the site column in the site collection.

Proceed with the following steps to resolve your issue:

Step 1.1

  1. Run the following PowerShell command to find the GUID of your site column
    $web = Get-SPWeb http://portal
    $columnName = "Your column name"
    write-host $web.Fields[$columnName].Title -nonewLine
    write-host " " $web.Fields[$columnName].Id
    $web.dispose
  2. Replace the GUID in the list with the GUID from the PowerShell. In most cases the GUID exists in 2 places in the list template
  3. Save the manifest.xml
     

Step 2

Now this is the fun/tricky part. You will need to assemble your manifest as a cab again. Run the following steps:

  1. Run command prompt and browse to the folder where your manifest.xml is
  2. Run the following command: makecab manifest.xml templatename.cab
  3. Rename your templatename.cab to templatename.stp
  4. Upload your new stp file to your list templates library

Problem solved!

 

  • Tuesday, November 14, 2017 By : Mike Maadarani    0 comment