Search This Blog

Sunday, May 1, 2011

Enabling Sharepoint list RSS settings programatically

RSS(Really Simple Syndication) is a great thing. Its a web format for delivering regularly changing web content. It allows you to easily stay informed by retrieving the latest content from the sites you are interested in. As a powerful content management tool, of course SharePoint enables RSS syndication for its contents.

Let’s take a look at the UI page where we can configure the RSS feed of a document library:
Step 1:

Step 2:

So, Is it possible to enable RSS settings exposed by a SharePoint library programmatically? The answer is yes, but unfortunately this task is not as straight forward as one might think. If you look the SPList properties, you will not find anything related to them. If you look at the SPListItems, you will not find anything related to them. So where are these properties? They are in fact in the RootFolder property of the list. The RootFolder is an object of type SPFolder and sets various properties for the files and contents associated with the list as a collection of items.

Code to accessing Rss feeds settings:
public void EnableRssSettings(SPList objSPList)
objSPList.EnableSyndication = true;
objSPList.RootFolder.Properties["vti_rss_DocumentAsEnclosure"] = 0;
objSPList.RootFolder.Properties["vti_rss_DocumentAsLink"] = 1;
objSPList.RootFolder.Properties["vti_rss_ItemLimit "] = 25;
objSPList.RootFolder.Properties["vti_rss_DayLimit"] = 7;


No comments:

Post a Comment