Geeks With Blogs
Adrian Hara Working through the .NET maze
Due to much frustration and lost time, I'll try to summarize in this post the "naming" conventions to be used when defining and/or referencing IDs (some of which are, in fact, GUIDs, and others contain GUIDs) in Sharepoint 2007.

If you're thinking "what the heck?! aren't GUIDs always the same format?!" you're half-right: they should be, but not in sharepoint. So if you're a newbie to sharepoint 2007 (or wss 3.0) like me, the following tips regarding how element id's should be written might save you some time (because if you get them wrong, the error messages from sharepoint are somewhat... cryptic). I've two conventions pinned down so far, but I'm just learning, so if you know any more, please share.

  1. Site Column definitions: defined using a <Field> xml element (more info on MSDN), their id's must have the form {GUID}. Note the brackets, they are mandatory, else you'll get an error (in the logs only) along the lines of "unable to locate the xml-field definition for FieldName with FieldId 'your_guid'". Another thing to remember is that the brackets are also mandatory wherever this site column is referenced (like in a content type). Thanks to Edwin Vriethoff for this tip.
  2. Content Types: as you probably know, the content type id is not actually a GUID, but a concatenation of the base content type id, "00" and a Guid. The catch here is that the Guid (third part in the concatenated string) must be written without dashes. So, instead of "0x010012B0E62B-D58E-4d6e-94A1-E36B3F7807E1", write "0x010012B0E62BD58E4d6e94A1E36B3F7807E1". Easy one to get wrong, especially if you use vs.net's guid generator in registry format. The error message from sharepoint in this case is very clear and helpful: "value does not fall within expected range" :)
It's actually too bad that 1) these gotchas exist and 2) the problems are not easy to figure out using the error messages from sharepoint. Hopefully, this post will help somewhat. Posted on Sunday, July 6, 2008 5:18 PM Sharepoint Gotchas | Back to top


Comments on this post: Sharepoint 2007 ID and GUID conventions

# re: Sharepoint 2007 ID and GUID conventions
Requesting Gravatar...
that is a quite useful information.
but i want know how the feature id of a particular feature can be find out in moss 2007.
is there any way to find it out?
Left by vinod bang on Mar 30, 2009 7:08 PM

# re: Sharepoint 2007 ID and GUID conventions
Requesting Gravatar...
hi can u tell me how to get the GUID of a site collection??
Left by vinod on Jul 03, 2009 6:56 AM

Your comment:
 (will show your gravatar)


Copyright © Adrian Hara | Powered by: GeeksWithBlogs.net