Returning GUID’s For Internal SharePoint Fields

So, a friend today asked me a pretty straightforward question.

What is the easiest way that one can grab the GUID of the internal fields that SharePoint provides? What is the most efficient, clear, and maintainable way across environments to consistently provide a reference to built-in fields such as:

Survey Title
The best way to do this is to use the SPBuiltInFieldId class. This is because it natively provides an identifiable way to access to all the internal fields that you would normally use, ensuring consistency and readability of your code.

For example, one could use it in combination with SPListItems when creating custom interfaces to standard SharePoint lists. You could even use this to create a metadata Hashtable, which is useful in its own right.

Normally, the way that several pieces of documentation will advise you to go about such a task is to pass in the field name that you want to insert something into by specifying a string literal coordinating to the field name, somewhat messy IMHO.

This would take on the form of:

SPListItemCollection listItems = SPWeb.Lists[“My List”].Items;

SPListItem item = listItems.Add();

item[“My Field”] = “string for insertion”;
This isn’t very good for several reasons, mostly because the field name is prone to typographic problems.

Now, let’s do the same thing, however using the SPBuiltInFieldId class.

SPListItemCollection listItems = SPWeb.Lists[“My List”].Items;

SPListItem item = listItems.Add();

item[SPBuiltInFieldId.{Type}] = “string for insertion”;


That type could take on many formats, depending on the exact field you are wanting to insert the values into. Instead of taking a string literal to insert the field, integrity is elevated since we are instead passing in the GUID as provided by the SharePoint OM.


No Comments


  1. SharePoint Link Love: 03-20-2008 at Virtual Generations - [...] [...]
  2. Links (3/20/2008) « Steve Pietrek’s SharePoint Stuff - [...] Returning GUID's For Internal SharePoint Fields [...]

Leave a Reply

Your email address will not be published. Required fields are marked *