Quick bites : Set Folder metadata default values on a SharePoint library using SharePoint CSOM

Posted by

One of the coolest functionality of SharePoint libraries is able to set custom metadata default values for folders. What it means is that when users drop a file into a folder, the metadata values of the file will be automatically set based on those set on the folder level.

However, if you have got about 50-100 folders then it becomes a tedious task to do. So, we could do it programmatically through SharePoint CSOM. Below is a quick snippet of code to set it using SharePoint CSOM where I am setting a taxonomy field default values.

Workaround for Azure Function TimeOut issue for Large number of folders

If you are using Azure Function, then you would hit the limit of function timeout (i.e. 10 minutes) while setting metadata for many folders such as 600 of them. So to overcome this limitation, you could use client_locationBasedDefaults.html override to set the metadata values directly. But please be aware that it might also corrupt the library if the above metadata setting up step is not done as below. The steps in this case would be

  1. Create a Test Folder
  2. Set the metadata values programmatically using the above process
  3. Delete the folder
  4. Override the client_locationBasedDefaults.html in the Forms folder of the library

So using the above steps, you could set metadata values for Folders in SharePoint libraries programmatically.

Happy Coding !!!

 

Advertisements

2 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s