Back to Insights

Working with advanced list options in SharePoint 2010

In my last article you read how to set item-level permissions on list items for both read and write access. In this article I wanted to dive into a few more functions that you see on the advanced settings page of the list: disabling list item attachments, specify whether the "New Folder" command is available, and specify whether this list should be visible in search results.

The last option that allows you to exclude the list from search results is particularly great. This option will not overwrite permissions to the list (i.e., users that have no access to the list won't see it anyway). It's still nice to be able to exclude the list from the crawl even if users have read-only access to improve the cleanliness of the search results.

As last time, I will present the list using the explicit specification, so that you can run it in a console application project:

SPSite site = new SPSite("http://localhost");
SPList userList = site.OpenWeb().Lists["MyList"];
// Specify whether this list should be visible in search results
userList.NoCrawl = true;
// disabling list item attachments
userList.EnableAttachments = false;
// Specify whether the "New Folder" command is available
userList.EnableFolderCreation = false;

In reality, you will probably end up running this in a feature receiver or in some sort of a portal configuration script or application.