Pregunta

I have created the site column named as "tags" as a taxonomy type of field.Also added into the content type. If i delete and re-add the content type , it's not working. it's throwing error 'A duplicate field name "Kac23234.." was found'. how to delete the note field using power shell script. anyone suggest the better idea to resolve this issue.

¿Fue útil?

Solución

Try below the Code, it will delete the taxonomy field with hidden note field.

function CleanUpSiteColumns($siteColl, $group){

$siteColumns = $siteColl.RootWeb.Fields | Where-Object{$_.Group -eq $group}
foreach($siteColumn in $siteColumns)
{
    $noteFieldId = $null

    Write-Host "Deleting " $siteColumn.Title

    #If it is a taxonomy field, get the id of the hidden note field
    if($siteColumn.GetType().Name -eq "TaxonomyField")
    {
        #TaxtField holds the Id of the hidden notes field            
        $noteFieldId = $siteColumn.TextField
    }

    #Delete the Site Column
    $siteColumn.Delete()
    #Write-Host $noteFieldId


    #If notes field is there, find it and delete it as well
    if($noteFieldId -ne $null)
    {
        $noteFields = $siteColl.RootWeb.Fields | Where-Object {$_.Id -eq $noteFieldId }
        if($noteFields -ne $null)
        {
            #Find the column
            foreach($noteField in $noteFields)
            {
                Write-Host "Deleting " $noteField.Title
                $noteField.Delete()
            }
        }
    }
}
}
  $siteCollection = Get-SPSite siteURL
  CleanUpSiteColumns $siteCollection "Taxonomy Columns"
Licenciado bajo: CC-BY-SA con atribución
scroll top