About      |       Articles      |      Services      |      Software      |      Contact

Latest Free SharePoint Software

ARB Security Solutions regularly releases free SharePoint software, including WebParts, Client Applications, Framework Extensions, and other Miscellaneous Components.
The most recent freeware is:

Title: Simple SharePoint Rollup WebPart
Date Published: 10/22/2009

Previous Two Free WebPart Releases:

SecureCenter For SharePoint

By SharePoint security integrators, for SharePoint security integrators.

SharePoint Security Assurance Program™

For externally facing SharePoint deployments, security is an acutely important deployment concern. Learn how through daily security scanning, you can ensure external business users and partners that they can collaborate in confidence!

Security Assurance WebPart:



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:

FullName
Picture
Survey Title
etc.
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:

C#:
  1. SPListItemCollection listItems = SPWeb.Lists["My List"].Items;
  2.  
  3. SPListItem item = listItems.Add();
  4.  
  5. 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.

C#:
  1. SPListItemCollection listItems = SPWeb.Lists["My List"].Items;
  2.  
  3. SPListItem item = listItems.Add();
  4.  
  5. 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.

  • Share/Bookmark

2 Comments »

  1. [...] [...]

    Pingback by SharePoint Link Love: 03-20-2008 at Virtual Generations — March 19, 2008 @ 5:37 pm

  2. [...] Returning GUID’s For Internal SharePoint Fields [...]

    Pingback by Links (3/20/2008) « Steve Pietrek’s SharePoint Stuff — March 20, 2008 @ 6:48 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment