0

I am adding a content type to a library using powershell. But it is throwing me this error:

Exception calling "Add" with "1" argument(s): "Field name already exists.
The name used for this field is already used by another field in the list.  Select another name and try again."
At c:\Add-ContentType.ps1:47 char:29
+                             $ctAdded = $spList.ContentTypes.Add($newContentType)
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : SPException

I am running the script on SharePoint 2016.

Edit: I created a new content type based on Document Set via the browser. I did not add any fields in it. The only fields available are the ones out of the box, Title and Description. Even that threw the error.

Anyone has got any idea?

2
  • Do you have any site column added in content type which has same internal name as any one of the list columns? – Ganesh Sanap Mar 26 at 16:10
  • Please read my edit above. – I-junior Mar 27 at 8:09
0

You either have an internal name or GUID conflict with another column being added to this list. Try removing all of the columns and adding them back one by one to find your problem child.

Here are some other references that may help:

Cannot add new column - "Field name already exists"

Field name already exists

0

Can you reproduce this error on other existing or new content types?

You can use this PowerShell script to find the column with same Internal Name, give a test with the out of the box columns as well.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
 
$web = Get-SPWeb "http://sharepoint.crescent.com/sites/operations"
$ColumnInternalName = "BranchLocation"
 
#Get All Content Types
$CTypes = $web.site.rootweb.ContentTypes
foreach($ContentType in $CTypes){
    $FieldInUse = $ContentType.FieldLinks | Where {$_.Name -eq $ColumnInternalName }
    if($FieldInUse -ne $null) {
        Write-Host "Found the Column in Content Type:" $ContentType.Name -ForegroundColor DarkGreen
        ##To Remove the field from content type, uncomment below two lines
        #$ContentType.FieldLinks.Delete($ColumnInternalName)
        #$ContentType.Update()
    }
}

Or you can manually remove the columns from the content type, except for the ones that you cannot remove, set column Status to Hidden and see the result.

Reference: Find SharePoint Site Column Usage - Report.

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.