Indexing Large Files in SharePoint 2010

Like it’s predecessor, SharePoint 2010 also doesn’t index files larger than 16 MB by default. This is because the search service application property ‘MaxDownloadSize’ is set to 16 MB by default. We can change this by running the following PowerShell commands and restarting search service.

$dSize = Get-SPEnterpriseSearchServiceApplication;
$dSize.SetProperty("MaxDownloadSize", 32);
$dSize.Update();

The above commands will increase the max size of files that SharePoint can index to 32 MB from 16 MB (default).

To restart search service, run the following command on the indexing server.


Restart-Service osearch14;

Advertisements

Programmatically Accessing SharePoint List XML Data in C# Code

SharePoint list data can be accessed in custom applications in C# without using SharePoint Object Model or Web Services. The list data can be retrieved as XML using a specific URL to the list (even using a web browser). This is described in this post. This URL can be requested from within the custom code to get the XML. The problem while creating an XMLReader object using the above URL is, it cannot authenticate the user (or application pool identity) into the SharePoint site unless anonymous authentication is enabled in the SharePoint site (which is false in most of the SharePoint implementations). A work around for this problem is to use HTTPWebRequest object to make a request to the list URL and to parse the response stream. Following is an example which takes app pool identity to authenticated into SharePoint site and to get the list data as XML.


String myURL = "<your site URL>/_vti_bin/owssvr.dll?Cmd=Display&List={List GUID}&XMLDATA=TRUE";
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(myURL);
myRequest.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
Encoding enc = System.Text.Encoding.GetEncoding(0);
StreamReader reader = new StreamReader(myResponse.GetResponseStream(), enc);
string result = reader.ReadToEnd();

The string “result” can be used to create an XML document.

If you are unable to use custom app pools for your web application (older versions of IIS) you can create a NetworkCredentail object to specify custom credentials. In order to do that, replace the line


myRequest.Credentials = CredentialCache.DefaultCredentials;

with the following block.


CredentialCache credCache = new CredentialCache();
credCache.Add(new Uri(myURL), "NTLM", new NetworkCredential("<user name>", "<password>", "<domain>"));
myRequest.Credentials = credCache;

SharePoint List Data as XML

Getting data as XML from a SharePoint List or Library is very helpful when we need to use the data in a custom application (developed using a programming language like C#) or in InfoPath forms. The data from a SharePoint list can be retrieved in XML format by using the following URL:

<your site URL>/_vti_bin/owssvr.dll?Cmd=Display&List={<list GUID>}&XMLDATA=TRUE

You can mention different parameters like “Query”, “FilterField” etc. for specifying columns to be retrieved and for filtering the quantity of data being retrieved. An example for these parameter options is below:

<your site URL>/_vti_bin/owssvr.dll?Cmd=Display&List={<list GUID>}&&XMLDATA=TRUE&Query=<column name>&FilterField1=<column name>&FilterValue1=<value>

The FilterFiled and FilterValue in pairs like FilterField1=<>&FilterValue1=<> and FilterField2=<>&FilterValue2=<> and such.

Delay in Updating SharePoint RSS Feeds in Outlook 2010

Most of time users may complain about RSS feed not getting updated in timely manner from SharePoint lists and libraries even though they have set the Send/Receive interval to shorter duration. This is because, in a SharePoint site, there is a minimum default time of one hour is set which RSS feed reader applications can request for update from RSS feeds in that site. This default minimum time can be changed by the site owner by performing following steps.

  1. Navigate to Site Settings > RSS (under Site Administration)
  2. Change “Time to Live (minutes)” to desired duration. Default is 60 minutes.

If you cannot change this property due to some reason (like organizational policy), you can instruct the complaining users to perform the following steps in Outlook to override this “publisher enforced delay”.

  1. In MS Outlook 2010, open Outlook Account Settings by clicking File tab > Account Settings > Account Settings…
  2. In the Account Settings screen, select RSS Feeds tab, select desired RSS feed from the list and click Change…
  3. In the RSS Feed Options screen, UNCHECK the Update Limit check box and click OK.
  4. Click Close on Account Settings screen

Now the RSS feeds will be synced according to the Send and Receive frequency you’ve set in Outlook. You can change the Send and Receive frequency by performing the following steps.

  1. Open Outlook Options screen by clicking File tab > Options
  2. In Outlook Options, select Advanced on the left hand side pane and then click on Send and Receive button on right.
  3. In Send/Receive Groups screen select the account you want (All Accounts by default) and change the Automatic Send/Receive schedule to desired duration.

SharePoint Tip: Best Timer Job is a Dumb Timer Job

Just came across this tip provided by Eric Gregorich from Secrets of SharePoint. It says “best timer job is a dub timer job”. What this means is, whenever you have to develop a SharePoint timer job which performs heavy tasks, extract the logic into another services that does the heavy tasks. This could be implemented as a workflow, a stored procedure or a custom web service. Then have the timer job calls this functions/methods. This helps the developers to easily debug and reuse the code. Thanks to Eric Gregorich for providing such a useful tip.

Document Library columns do not show up in View Properties/Edit Properties page

If you run into the issue where SharePoint 2007/2010 Document Libraries does not show some of the columns in View Properties/Edit Properties page, check if the columns are included in the default content type of the library. In order to do that,

  1. Go to document library settings > Advanced settings
  2. Select “Yes” for “Allow management of content types?” radio buttons and click OK
  3. Under the Content Types section in document library settings, click on the name of default content type (eg: “Document”) and check if the columns are present
  4. If the columns are not listed, click on “Add from existing site or list columns”, select desired columns in the list box on left, add them to list box on right and click OK.
  5. Go to advanced library settings again, select “No” for “Allow management of content types?” radio buttons and click OK.