Difference between StaticName and InternalName (in class SPField)

I want to make the CAML request semi-smart - in that I can give it a Title (this is what the end user sees), and it looks for the appropriate “Title” for transmission as part of the CAML request:

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

It looks like I can iterate over the Fields collection from a list using the object model, and then turn off the Title property to compare with what the user sees. My question is using StaticName and InternalName. My gut + MSDN documentation seems to indicate that InternalName is the correct property to use and replace a field in the above code, especially because InternalName cannot be changed.

Can anyone shed some light on this?

+3
source share
1 answer

check this question on msdn forums:

Title Vs. Static name

When creating site columns in CAML, only the "Name" attribute is required, which maps to SPField.InternalName in the object model, you do not need to set the StaticName attribute. Accordingly, SPField.InternalName and SPField.StaticName will return the same value. But if you set the StaticName attribute to CAML, SPField.InternalName will return the value specified in the Name attribute, and SPField.StaticName will return the value specified in the StaticName attribute.

+7
source

Source: https://habr.com/ru/post/1712240/


All Articles