Column Default Value Settings based on Location in SharePoint
While it’s possible to set default values for SharePoint columns at library level at field settings, What if you want to set the default column value of a document based on the folders it’s saved? SharePoint Server / SharePoint Online provides a new feature to set metadata values based on the location!
How to Set Default Metadata from Document Location?
Say, We have a document library with “Department” column and with few folders namely “Sales”, “Marketing”, “IT”, etc. as in this screen.
And we want the metadata field “Department” value based on the location.
Set Column Default Value Settings in SharePoint
- Go to the List / Library >> Click on Settings >> List settings. In the list settings page, select “Column default value settings “.
- Click on the desired metadata column link of the respective folder(s)
- and set the value for it
When users upload a new document to different folders, the “Department” field gets value from this setting automatically. This doesn’t change the metadata on all existing documents, BTW!
Have used Set-PnPDefaultColumnValues to update the folder default values, it was successful.
Set-PnPDefaultColumnValues -List Documents -Field TaxKeyword -Value “TermGroup|TermSet|Term” -Folder “Folder/SubFolder”
However, I have noticed once it gives an error by chance (due to wrong value or from typo in CSV), then it doesn’t let me use PowerShell anymore for that library.
Error: Set-PnPDefaultColumnValues : Index was outside the bounds of the array.
Naidu Kumapatla, I deleted the folder with the default value error and emptied both Recycle Bin stages, and I was able to continue with the library, but if I readd the same folder name (which had the default value error), the error returns. Clearning the default value does not fixt the problem:
Clear-PnPDefaultColumnValues -List Documents -Field TaxKeyword -Folder “Folder/SubFolder”
is this possible via powershell script?