Mar/12
2010

SPView.ViewFields is a collection of internal field names, according to MSDN. (It is not a list of display names, as can be seen by examining the view fields of the 'UserInformationList' list).

This is surprisingly inconvenient, as SPList.Fields is indexed only by display name (or GUID, or index), and not by internal name at all.

Therefore, to map from internal names (such as are held in SPViewFields, or are encoded in CAML expressions), one cannot simply use the SPList.Fields accessor. One needs first build a dictionary mapping all internal names to something useful (e.g., GUID).

I can only guess that the SharePoint internal code uses some other (inaccessible) means for finding fields from the internal names -- which it must do frequently in rendering views and CAML.

2 comments
Comment from: AKrasheninnikov [Visitor] Email · http://twitter.com/akrasheninnikov
AKrasheninnikovBut you can use either http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfieldcollection.getfieldbyinternalname(v=office.14).aspx or .Fields[displayname].InternalName
05/27/10 @ 04:29
Comment from: Perry [Member] Email
PerryGood point. I changed my code to use GetFieldByInternalName (which is available in Office.12 version == MOSS2007 as well).
05/27/10 @ 12:36
Leave a comment

Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)