Home > SharePoint 2010 > Name vs. Static Name in Caml

Name vs. Static Name in Caml

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.
I didn’t face a situation where I needed them to be different. So I always leave the StaticName attribute alone and only set the Name attribute in CAML. However Microsoft in its OOB colums just set StaticName value to the same of Name.There is no way we can change the internal name of a field after provisioning. I know that the documentation states that we can change the internal name via the SPField.StaticName property but this is not true.

One problem I found is that, if you use reserved Name like “Company” to create a Field, it will break the calculated field UI in SharePoint. This does not happen when creating field using UI, because you cannot use reserved word to create field using SharePoint UI.So you need to take this into consideration when creating field using CAML in Visual Studio. You can download a solution to demonstrate this problem here.

References:

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/fdb2f0f2-1d56-484b-a81a-0a6e42d34b50/

Advertisements
Categories: SharePoint 2010 Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: