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.
There are 2 possible causes to your issue:
Your list template is referencing the same field twice
Your list template is referencing a field tat already exist in the site collection but with a different GUID
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
Save your template.tsp to your desktop
Rename your template.tsp to template.cab
Extract your template.cab to a specific location
Edit the manifest.xml
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:
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
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
Save the manifest.xml
Now this is the fun/tricky part. You will need to assemble your manifest as a cab again. Run the following steps:
Run command prompt and browse to the folder where your manifest.xml is
Run the following command: makecab manifest.xml templatename.cab
Rename your templatename.cab to templatename.stp
Upload your new stp file to your list templates library