Wednesday, April 16, 2008

Using [Today] in SharePoint calculated fields

I revisited my previously used SPS2003 old trick to force the usage of [Today] value in calculated fields, such as doing a [Created]<[Today]. I think I’ll note it down here for future reference.

By default, SharePoint will not allow creation of a calculated field that is partly derived base on functions such as [Today]. Therefore, the work around is to “trick” SharePoint, literally. This is done by deliberately creating a field call [Today] that of a single line of text (or anything else), then create your calculated field using this text-base [Today] field, e.g. [Created]<[Today]. Once you’re done creating the calculated field, remove the fake [Today] field. Once this is done, the calculated field will make use of the actual [Today] function and calculate your date value accordingly. This article from Chris Johnson has more detail on this approach.

However, do note that there are limitations in using this method since the introduction of content type and site column in MOSS 2007. If you are creating content type up front instead of creating a list the SPS2003 method, you must make sure you do not remove the fake [Today] column from the content type immediately after you’ve created your calculated field. Doing so will prevent you from setting your content type into your list or document library, as SharePoint will perform a round of validation to ensure you do not use [Today] in your fields. Instead, remove the fake [Today] field after you’ve set them into your list or document library.

Also, think there should be a reason why creation of calculated field with [Today] in it is prevented. One reason I can think of is probably for performance reason. Imagine loading a big list and exposing the calculated field. Each rendering of this field might probably invoke the [Today] function, which at the end gives some performance hit to the loading. Therefore, should try to avoid using this method unless it is necessary.

MOSS 2007 Formulas and Functions

While working with calculated fields, I’ve found the Formulas and Functions page from Microsoft Office official site which contains listings of formulas and functions that can be used. Some of the functions provided are Date and time, Financial , Information, Logical, Lookup and reference, Math and trigonometry, Statistical, and Text and data. For quick reference, refer to Common Formulas page of often used formulas.

Friday, April 11, 2008

Exporting MOSS Content Type as a Feature

While going through on the best approach on developing content type for the portal I’m currently working on, I’ve stumble across this very cool tool call CTExplorer. It a content type browser, with the ability to export a selected content type into a feature. Therefore, instead of creating feature up front (ouch!), I can build the content type in MOSS 2007, and export it out later. Now that’s sort of like reverse-engineering.

CTExplorer can be found at this page, or download it directly at here. The page is in German, but you can translate it easily if required. I haven’t try out whether it works or not, so I’ll update this post once I’ve tried it out.

Update 2011-01-17: Apparently there is a more complete tool for exploring your SharePoint instance now, call the SharePoint Manager. It's available in Codeplex at

Thursday, April 10, 2008

Enable VS 2008 integration with VSS 2005

To enable source control in Visual Studio .NET 2008 , you’ll need to install a CTP update for Visual SourceSafe 2005. Download it here. For reason why there’s such problem, refer to here.

Updated 20081223: Windows Vista workstation may need to include this service pack. Also, depending on the sequence of installation, you may need to turn on the VSS integration manually in VS.NET, under Tools -> Options -> Source Control.

Thursday, April 3, 2008

MOSS 2007 Performance Limitations

While determining the taxonomy for the portal I’m working on, I was thinking whether it should be one with a flat structure or lots of deep subsites. The software boundaries for MOSS 2007 article on MSDN provides a good guideline on my taxonomy design. The following guideline table comes from the article:

Site object

Guidelines for acceptable performance


Scope of impact when performance degrades

Site collection

50,000 per content database

Total farm throughput degrades as the number of site collections increases.


Site collection

150,000 per Web application

This limit is theoretical, and is dependent largely upon:

· Performance of the database server on which the configuration database resides.

· Performance of the Web servers in the farm.

· Network bandwidth between the Web servers and the database server.

This is not a hard limit, and assumes a single database server. Your environment may not be able to host this many site collections per Web application. Distributing content databases across additional database servers can increase the effective limit of the number of site collections per Web application. You should perform testing to determine the actual effective limit in your environment.


Web site

250,000 per site collection

You can create a very large total number of Web sites by nesting the subsites. For example, 100 sites, each with 1000 subsites, is 100,000 Web sites. The maximum recommended number of sites and subsites is 125 sites with 2,000 subsites each, for a total of 250,000 sites.

Site collection


2,000 per Web site

The interface for enumerating subsites of a given Web site does not perform well as the number of subsites surpasses 2,000.

Site view


5 million per library

You can create very large document libraries by nesting folders, using standard views and site hierarchy. This value may vary depending on how documents and folders are organized, and by the type and size of documents stored.



2,000 per view

Testing indicates a reduction in performance beyond two thousand items. Using indexing on a flat folder view can improve performance.

List view

Document file size

50MB (2GB max*)

File save performance is proportional to the size of the file. The default maximum is 50 MB. This maximum is enforced by the system, but you can change it to any value up to 2 GB.

Library, file save performance


2,000 per Web site

Testing indicates a reduction in list view performance beyond two thousand entries. For more information about large lists, see White paper: Working with large lists in Office SharePoint Server 2007.

List view

Field type

256 per list

This is not a hard limit, but you might experience list view performance degradation as the number of field types in a list increases.

List view


2,000 per document library

4,096 per list

This is not a hard limit, but you might experience library and list view performance degradation as the number of columns in a document library or list increases.

Library and list view

Web Part

50 per page

This figure is an estimate based on simple Web Parts. The complexity of the Web Parts dictates how many Web Parts can be used on a page before performance is affected.


Go to for more details.

Tuesday, April 1, 2008

Audience Targeting won't work with AD Group in MOSS User Group

I’ve already know about this issue and got “bitten” again today. I’m making sure that I’ll remember this time by blogging it.

Audience Targeting now works with MOSS Group as well without a need to create audience rule and compiling them. However, the users must be added to the MOSS user group directly for it to work. Adding AD user group into the MOSS user group will not work. Instead, add the AD group directly when specifying the audience targeting for the web part.

Another side effect of that also means you wouldn’t be able to find out the user’s MOSS group if he is added to the MOSS group via an AD group. The following code gives me no MOSS group at all, even though the person is already added into the MOSS group via AD group:

SPUser user = web.CurrentUser;

Foreach (SPGroup group in user.Groups)


                Str += group.Name + “<br/>”;


Therefore, do take note of this when you plan to roll out some custom functionality which is base on MOSS user groups.

Tool for registering SharePoint 2007 event handler programmatically

Found this great tool by Patrick Tisseghem's Blog [MVP SharePoint] for registering SharePoint 2007 event handlers to specific list or document libraries. Works like a charm on my MOSS 2007 SP1 VM. Great for quick deployment for development/testing purposes. Download it from his blog page here:

MOSS Event Handler