How to crawl Lookup field or column

By Namwar Rizvi - Last updated: Sunday, October 5, 2008

Whenever you create a column in your list and want to enable search based on it then you add that column as a Managed Propety in your Shared Service Provider. It works for all type of columns except lookup columns, which actually refers to another list in the site, without needing any further steps. The difference in lookup columns is that they actually save just a reference not the actual value and if you have created a column with the name say Category ( having values Hardware, Software, etc) and add it as a managed property then you will see that you will not get any result if you will try to search by say Hardware,a value from the Category list, because internally only reference was saved and SSP indexed the reference not the actual value.

But don’t worry, there is a simple solution which unfortunately Microsoft has not documented properly. The solution is, just go back and edit your managed property mapping and instead of mapping Category; map ows_Category. This is an internal property generated by the Sharepoint when you created Category and this property saves the actual value.

Now, after doing the crawl, if you will search as before, you will get the expected result.

Filed in Architecture, SSP • Tags: , ,

Update List Item without changing Modified By and Modified fields

By Namwar Rizvi - Last updated: Tuesday, September 30, 2008

If you update a field of a SPListItem obeject from code by using the following code snippet

item[“Title”]=”Updated Title”;


then you will notice that Modified By  and Modified field will be updated also. Sometimes, you just want to update fields without changing Modified By and Modified fields, you can do so by using 


instead of item.Update();

SystemUpdate() method just updates the intended field values.

Filed in Object Model • Tags: , ,

How to check if the file is indexed in SharePoint or not?

By Namwar Rizvi - Last updated: Wednesday, September 17, 2008

If you want to know whether your file is indexed in Sharepoint Search Services Provider (SSP) or not then there is no way provided directly in the object model of SSP.

Since Sharepoint stores its content on SQL Server therfore, you can run the following TSQL query to find it:

Select * from dbo.MSSAnchorText where Link='<Your File Path>'
Note: Please note you need to replace <Your File Path> by the full path of the your intended file in the above query
Select * from dbo.MSSAnchorText where Link='http://mossdev/Shared%20Documents/UserManual.pdf'
Filed in Object Model, SSP • Tags: , , , ,

How to get raw XML of Sharepoint Search Core Results Web Part?

By Namwar Rizvi - Last updated: Friday, September 12, 2008

If you are like me and trying to customize the search result presentation in SharePoint then you must have faced the issue of customizing the XSL of Sharepoint Search Core Results Web Part. You can customize the XSL by using SharePoint Designer or any other WYSIWYG XSL editor, if you know the raw XML returned by Search.

To get the raw XML click XSL Editor button of Search Core Results web part and replace the already provided XSL with the following

<xsl:stylesheet version=”1.0″ xmlns:xsl=”” >

<xsl:output method=”xml” version=”1.0″ encoding=”UTF-8″ indent=”yes” />

<xsl:template match=”/”>

<xmp><xsl:copy-of select=”*”/></xmp>



Filed in Customization • Tags: , , ,

How to remove or Extend New! Item tag for Sharepoint List Items

By Namwar Rizvi - Last updated: Sunday, September 7, 2008

Whenever you add a new item in any Sharepoint list “New!” item tag displays against that item for a time being. The time to display this tag depends on a property called “Days to Show New Icon”. The value of this property determines the number of days to display the New! tag against an item.

If you set this property to zero then newly added items will not have this tag. On the other hand if you want to display this tag to be displayed longer then usual then you can set its property in number of days as per your requirement.

Following is the step-by-step procedure to do that:

  1. Click Start, point to All Programs, point to Accessories, and then click Command Prompt
  2. Type the following commands, and then press ENTER after each command:
    cd /d %programfiles%\Common Files\Microsoft Shared\Web Server Extensions\12\BIN
     stsadm.exe -o setproperty -pn days-to-show-new-icon -pv 0 -url [Your Virtual Server’s URL]
Filed in Configuration, Management • Tags: ,

Moving Sharepoint Portal from one server to another server

By Namwar Rizvi - Last updated: Thursday, August 28, 2008

I found following article quite informative to move Sharepoint Portal from one server to another server.

It describes step-by-step procedure to move databases from one machine to another machine and how to attach them.

Filed in Configuration, Management • Tags: ,

How to disable My Site functionality?

By Namwar Rizvi - Last updated: Wednesday, August 27, 2008

If you want to disable My Site or My Links functionality, here are the steps to follow:

  1. Open Central Administration site
  2. Under Shared Services Administration click your Shared Services Provider (SSP) which is running your  My Site functionality
  3. Under User Profiles and My Sites, click Personalization  Services Permissions
  4. Here you can assign different permission set for different users and groups for Personalization functionality.  For example
    1. To disable My Site functionality for all users click NT Authority\Authenticated Users group and uncheck Create personal site
    2. To disable My Links uncheck User personal features
  5. Click Save
  6. Repeat above steps to individually manage Personalization for different users and groups
Filed in Management • Tags: ,

Sharepoint best practices: how many sites, how many libraries

By Namwar Rizvi - Last updated: Tuesday, August 26, 2008

While browsing Sharepoint newsgroups, I found a very useful reply from Eddy Blanco which provides excellent information to estimate your SharePoint site and structure. Following is the information, all credit goes to Eddy Blanco:

SharePoint Area of Interest Optimum Size
Site collection 50,000 per Web application
Web site 250,000 per site collection
Subsite 2,000 per Web site
Document 5 million per library
Item 2,000 per view
Document file size 50MB (2GB max*)
List 2,000 per Web site
Field type 256 per list
Column 2,000 per document library 4,096 per list
Web Part 50 per page
Users in groups 2 million per Web site
User profile 5 million per farm
Security principal 2,000 per Web site
Search indexes One per SSP, Maximum of 20 per farm
Indexed documents 50,000,000 per content index
Content sources 500 per SSP
Start Addresses 500 per content source
Alerts 1,000,000 per SSP
Scopes 200 per site
Display groups 25 per site
Crawl rules 10,000 per SSP
Keywords 15,000 per site
Crawled properties 500,000 per SSP
Managed properties 100,000 per SSP
Authoritative pages 200 per relevance level
Results removal 100
Crawl logs 50,000,000
Shared Services Provider (SSP) 3 per farm (20 per farm maximum)
Zone 5 per farm
Web application 99 per SSP
Internet Information Services (IIS) application pool 8 per Web server
Site collection 50,000 per Web application
Content database 100 per Web application
Site collection 50,000 per database
Index servers 1 per SSP*
Application servers running Excel Calculation Services No limit
Query servers No limit
Web server/database server ratio 8 Web servers per database server
Web server/domain controller ratio 3 Web servers per domain
Filed in Architecture • Tags:

SPDiffUtility: An excellent class to find differences in strings with HTML highlighting

By Namwar Rizvi - Last updated: Monday, August 25, 2008

While exploring Sharepoint utility classes, I found an excellent class which deserve more credit then it currently enjoys. It is SPDiffUtility. This class has only one static method called Diff which determines the text differences between two strings. It takes three parameters:

  1. str1: The original string
  2. str2: The changed string
  3. maxDifferences: A 32-bit integer representing the maximum number of differences to find.

The beauty of this function lies in its return value which is a merged version of the specified strings that contain HTML tags indicating inserted, deleted, or changed text.

This returned string contains HTML tags to highlight the changes, insertions and deletions. The best part is that you can set these tags with your HTML tags if you want. Following is the sample usage of this class.

  1. Create a web site project in Viusal Studio
  2. Add reference to Microsoft.Sharepoint.dll found in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI\Microsoft.SharePoint.dll
  3. Paste the following code in Default.aspx
  4. <%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs” Inherits=”_Default” %>
    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “”>
    <html xmlns=””>

    <head runat=”server”>
    <title>Untitled Page</title>

    <style type=”text/css”>
    .ms-diffdeletenostrike {
    BACKGROUND-COLOR: #e0e0e0;
    .ms-diffdelete {
    BACKGROUND-COLOR: #e0e0e0;
    .ms-diffdelete {
    TEXT-DECORATION: line-through;
    .ms-diffinsert {
    BORDER-RIGHT: #ffffff 1px solid;
    BORDER-TOP: #ffffff 1px solid;
    = BORDER-LEFT: #ffffff 1px solid;
    BORDER-BOTTOM: #ffffff 1px solid;
    = BACKGROUND-COLOR: #ffeaad;

    <form id=”form1″ runat=”server”>
    <asp:Label ID=”lblResult” runat=”server” Text=””></asp:Label>



  5. Open Default.aspx.cs and paste the following code

  6. using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using Microsoft.SharePoint.Utilities;
    using System.Diagnostics;

    public partial class _Default : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
    string firstString = “This is an initial string”;
    string secondString = “This”;

    //Set the tags
    SPDiffUtility.ChangeOpenTag = ““;
    SPDiffUtility.ChangeCloseTag = “
    SPDiffUtility.InsertOpenTag = ““;
    SPDiffUtility.InsertCloseTag = “
    SPDiffUtility.DeleteOpenTag = ““;
    SPDiffUtility.DeleteCloseTag = “

    //end setting tags

    //Find the difference
    string diffString = SPDiffUtility.Diff(firstString, secondString, Int32.MaxValue);
    lblResult.Text = diffString;


  7. Run web application by pressing Ctrl+F5

You will see “This is an intial string where striked out letters are those which have been deleted in the second string.

Filed in Object Model • Tags: ,

How to find End Date Pattern in Sharepoint Recurring Event

By Namwar Rizvi - Last updated: Monday, August 18, 2008

Sharepoint recurring events are similar to Outlook recurring events and provides several options to specify End Date pattern. If you find the type of End Date pattern in a recurring event you can find it in AfterProperties field of SPItemEventProperties object. Just check following


Following are possible outputs and their meaning

Filed in Event Handler, Object Model • Tags: