0

In SP Online, I'm trying to delete a "Managed Metadata" column in a library but getting the below error in UI and also in PowerShell:

Error: Cannot change Hidden attribute for this field

On googling, I found that "CanToggleHidden" property has to be set to "True" and then "Hidden" property has to be set to "False" to fix this issue. So,I executed the below PS Script to apply these changes:

$SiteURL = "https://ABC.sharepoint.com/sites/Intranet"
$ListName = "Site Pages"
$FieldName = "CandC_Color" #Internal Name
Try {
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -UseWeblogin
#Set Field Properties
Set-PnPField -List $ListName -Identity $FieldName -Values @{CanToggleHidden="True";Hidden=$False}   
}
catch {
write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}

While executing this PS script I get the below error and not able to delete the "Managed Metadata" column

> WARNING: No property 'CanToggleHidden' found on this field. Value will be ignored.

Kindly assist on this issue and guide if there are any other options to delete the column?

2
  • Can you try this: Remove-PnPField -List $ListName -Identity $FieldName instead of Set-PnPField cmdlet? Let me know if it works for you. Apr 20, 2023 at 10:31
  • @GaneshSanap No, it didnt work, I get the error "Error: Cannot change Hidden attribute for this field"
    – George
    Apr 20, 2023 at 10:55

1 Answer 1

0

For each Managed Metadata field we create SharePoint will create another (hidden) field, which is probably the one raising the first error. Run the following to verify it (you will find a field called "CandC_Color_0" with type Note):

Get-pnpField -list "SampleList" | select Title, InternalName, TypeAsString

the result of a Get-PnPField command

The complete list of field properties can be found at this location: https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-csom/ee536438(v=office.15) . You will see that indeed there is no "toggleHidden" property, it is just "Hidden". (the schemaXML may include it, but since there is not property you cannot update it this way).

To remove a field (even a managed Metadata one, and should also automatically delete it's hidden sibling) the following should be sufficient:

Remove-PnPField -Identity "MMField2Delete" -List "SampleList"
3
  • I am able to see the Sibling column and executed the command suggested by you. But I still get the same error "Error: Cannot change Hidden attribute for this field"
    – George
    Apr 20, 2023 at 6:45
  • What I meant is that you shouldn't try to delete the hidden field, deleting the "TaxonomyFieldType" field should automatically delete the hidden one too.
    – dinos.kon
    Apr 20, 2023 at 6:58
  • Yes, i tried deleting the "TaxonomyFieldType" field and received the error
    – George
    Apr 20, 2023 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.