Tuesday, May 20, 2008

MOSS Managed Property

Assume you have a publishing site which has a List called company which contains company information. The company list has a column named Active of type Yes/No. We want to filter the global search results to hide the inactive companies for public internet users.

1. Create a scope called Internet User. Add a scope rule with All Content to it.
2. Create a Custom List called ListActive, add two list items 'yes' and 'no'.
3. Add a Site column called IsActive of type lookup and reference the ListActive list.
4. Add the IsActive site column to the Company List.
5. For the managed property to work, we need to use site column, so here we are replacing the Active column of Company List with IsActive site column, and delete the Active column from the company List once we've copied the data from Active to IsActive column.
6. If you only have a few companies in the Company List, you could just copy the data from Active column to the IsActive column by editing the list in an Access datasheet.
7. In this case we have hundreds of companies, I am going use the following program to do it:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
namespace ListSolution
class Program
static void Main(string[] args)
public static void Copy_Data_To_IsActive_Column()
SPSite rootSite = new SPSite(http://sitename/);
SPWeb web = rootSite.AllWebs[""];
SPList taskList = web.Lists["Company"];
foreach (SPListItem item in taskList.Items)
if (item["Active"] != null && (bool)item["Active"])
//this is how you update lookup column, 0 is null, 1 is yes, 2 is no
item["IsActive"] = 1;
item["IsActive"] = 2;










8. Start an Incremental Crawl of the 'Local Office SharePoint Server Sites' content source.

9. Add a new Managed Property called CompanyActive as follows:

10. Click Add Mapping, a pop up shows as follows. Choose SharePoint, find the IsActive Column,click OK.

11. Add a rule to the Internet User scope. Select Property Query then select CompanyActive property equals No. Select exclude.

12. Add the scope to the Search Core Results Web Part.
blog comments powered by Disqus