views:

625

answers:

1

I want to make a CAML query semi-smart - in that I can give it a Title (which is what the end user sees) and it looks up the appropriate "Title" to pass as part of the CAML query:

var caml = "<OrderBy><FieldRef Name='" + field + "'/></OrderBy>";

It looks like I can iterate of the Fields collection of the list using the object model, and then key off the Title property to compare with what the user sees. My question lies in the usage of StaticName versus InternalName. My gut + the MSDN documentation seem to indicate that InternalName is the right property to use and replace field in the above code - particularly because InternalName can't be modified.

Can anyone shed light on this?

+3  A: 

check out this question on msdn forums:

Name Vs. Static Name

When creating the Site Columns in CAML, only "Name" attribute is required which maps to SPField.InternalName in the object model, you don't have to set the StaticName attribute. Accordinly SPField.InternalName and SPField.StaticName will return the same value. But if you set the StaticName attribute in CAML, SPField.InternalName will return the value specified in the Name attribute and SPField.StaticName will return the value specified in the StaticName attribute.

Colin