Skip to content

Set-PnPDefaultColumnValues Index was outside the bounds of the array #2145

Closed

Description

@MichaelGaardbo

Hi,

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.

Using: PnP.PowerShell 1.11.0

Activity

  1. denicomp commented on Jul 14, 2022

    @denicomp

    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.

  2. locked and limited conversation to collaborators on Jul 14, 2022
  3. converted this issue into a discussion #2149 on Jul 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions