Sunday, December 1, 2013

Sharepoint Delete Hidden Site Columns

the errors you might get:
"Cannot change Hidden attribute for this field"
"cannot delete hidden column"

reason: http://sadomovalex.blogspot.co.il/2012/01/avoid-cannot-change-hidden-attribute.html

solution: run this Poweshell:

$web = Get-SPWeb http://YourSite/YourWeb
$list = $web.GetList("/YourWeb/Lists/YourList")
$field = $list.Fields.GetFieldByInternalName("YourFieldInternalName")
$type = $field.GetType()
$mi = $type.GetMethod("SetFieldBoolValue",
    [System.Reflection.BindingFlags]$([System.Reflection.BindingFlags]::NonPublic -bor
    [System.Reflection.BindingFlags]::Instance))
$mi.Invoke($field, @("CanToggleHidden",$true))
$field.Hidden=$false
$field.Update()

$field.Delete()

No comments:

Post a Comment