You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Set-PnPDefaultColumnValues Index was outside the bounds of the array #2145
I'm trying to set a default value on a managed metadata column on a subfolder however I get: Set-PnPDefaultColumnValues : Index was outside the bounds of the array.
I've tried different approaches:
$DocumentType = "Group|TermSet|TermValue" or $DocumentType = "wssid;#label|guid" or $DocumentType = "Guid of Term"
$FolderPath = "/Folder1/Folder2" or "Folder1/Folder2": Set-PnPDefaultColumnValues -List "ListName" -Field "FieldInternalName" -Folder $FolderPath -Value $DocumentType -Connection SPsiteConnection
I've tried on a Single line of text column as well and same result: Set-PnPDefaultColumnValues : Index was outside the bounds of the array.
On a side note: I played around with the -list parameter when I was testing and the strange thing is that if I put in a wrong value (non existing list) for -list it does throw any exception.
My issue with Set-PnPDefaultColumnValues using managed metadata is that eventually, if used enough times, it will fail with the "Index was outside the bounds of the array". And it corrupts the default column values in the library, and the only way to fix it is to delete and rebuild the library.
In the example code I posted in the issue above, it happens after 3 calls.
This occurs when I use a Custom Property on a term and use it on folders more than 2 levels deep.
But it will eventually occur even without Custom Properties and folders 1 level deep, it just takes many more calls to Set-PnPDefaultColumnValues. But eventually it happens. There is no reason I can pinpoint,
But once it occurs (after successful calls), you can never use it again on that library - it will fail every time.
I do not see this behavior with Text fields however (so far). Only managed metadata fields.
Activity
denicomp commentedon Jul 14, 2022
Have you tried not using the "FieldInternalName" and use the Display Name of the field?
I am able to get Set-PnPDefaultColumnValues to work. See the example code I put in the issue I opened yesterday:
#2143
My issue with Set-PnPDefaultColumnValues using managed metadata is that eventually, if used enough times, it will fail with the "Index was outside the bounds of the array". And it corrupts the default column values in the library, and the only way to fix it is to delete and rebuild the library.
In the example code I posted in the issue above, it happens after 3 calls.
This occurs when I use a Custom Property on a term and use it on folders more than 2 levels deep.
But it will eventually occur even without Custom Properties and folders 1 level deep, it just takes many more calls to Set-PnPDefaultColumnValues. But eventually it happens. There is no reason I can pinpoint,
But once it occurs (after successful calls), you can never use it again on that library - it will fail every time.
I do not see this behavior with Text fields however (so far). Only managed metadata fields.