Sharepoint gotcha

The GetSiteData method on the SPWeb returns all of the columns as datatype string.  This does not appear to be documented anywhere.  It is however the only single method that can query across lists.

CAML is a very weak query language.  You can’t do much in the way of joins.

A tale of three guids

A tale of three guids:

Sharepoint

Features require a guid of the form “this-is-a-guid”

For a content type you need a guid of the form “0x100thisisaguid”

For a field definition you need a guid of the form “{this-is-a-guid}”

 

One team, three distinct guid formats WTF

Debugging Feature Receivers

A great technique when developing a sharepoint feature receiver:

Create yourself an announcements list and have the feature log the install (or failure to do so) to this location.

 This is much less messy than debugging on a production box.

 This announcement list can be locked down so only developers and admin’s can read it.

 I have found that you can create and populate a custom list and a view in 20 lines of code (genericly).

 This contrasts to 4000 lines of xml per list/view.

Enterprise Search and the BDC

This is an article on configuring the BDC to work with Enterprise Search.

The BDC is a database/web service abstraction layer that provides a unified api.
It claims to be of general use in Sharepoint.

I can see little benefit to it if you don’t want google like searches of your application.
The big problem is that you need to be very careful or the search mechanism will invalidate any access controls that you have.

The BDC is excessively complex for what it provides.  The price in it’s complexity (as is generally the problem with sharepoint) exceeds the effort required to roll it yourself…

Sharepoint Best Practice

The recommended practice for adding items to a sharepoint site is to use features.
One useful technique is to create a feature with an activation receiver.
When you install and activate this you can do whatever you like to the site in code.

The problem is keeping track of what you have done (and did it work).
I would recommend creating a private announcement list that the installer feature writes to.
This makes it easy to check that the install has worked (especially in a SOX environment where you won’t be the one running the script).

Sharepoint Warning

I have been investigating creating custom content types in Sharepoint and basing lists off of them.
I have been working with the feature xml documents.

There is an insideous bug that you need to be aware of: the name and the guid for a custom field must both be unique.
If you reuse the name of a field when creating a custom type then when the type is activated the duplicate field will be silently dropped – no warnings or errors.  This took me a day to track down – I was wondering why the view that I built on a list was missing some columns. When I checked these were thecolumns that I had used in an earlier prototype.

There is another catch – you may need to recycle the app pool between un-registering and re-registering features.  Sharepoint seems to prefer to use the cached values rather than the newly supplied ones.

The above was exasperated by the substandard documentation supplied with the product.  While there is lots to read, it is incomplete and contains errors.

It appears that Sharepoint 2007 was realeased too soon – the internal design is not consistent (three styles of guid are required to register a content type!), the error handling is patchy – varies from excellent (exactly which field is incorrect) to vague (a field is wrong somewhere).