0

In working with SharePoint and spServices, I've run into many different ways of naming fields that depends on what you're trying to do. What are these naming schemes called?

Let's say in SharePoint I add a column to a list, and call it "Hello World". Now, via SOAP/XML experimentation, I can see that depending on context, the field could be called:

  • Hello World (visible to the user)
  • ows_Hello_0x200_World (the name of an XML attribute inside of a SOAP response)
  • Hello_0x200_World (the name that you would use if you were implicating the column in a CAMLQuery) -- via this question I learned that ows_Hello_0x200_World won't work as part of a CAMLQuery)

To further complicate things, sometimes the SOAP response truncates particularly long attribute names at a certain number of characters, so sometimes you don't even get the entire attribute name back! Sometimes the SOAP layer will respond with ows_A_0x200_Really_x0200_Lo as the name, rather than A Really Long Attribute Name.

Do these different schemes themselves have names, and is there any documentation available on when to use each one?

2 Answers 2

1

Hello World - this is the field's display name (as you noted, which is visible in the UI), which in the object model is the SPField.Title property. If you are creating the field from the UI, this is what you specify initially as the field's name.

Hello_0x200_World - this is the field's internal name, which in the object model is the SPField.InternalName property. As you can see, when adding a field from the UI, SharePoint will do some encoding when it creates the internal name. If you are creating the field declaratively in VS, you can specify exactly what you want the internal name to be. (More info on Field Definitions.)

As Pirate Eric mentioned, a common technique to control the encoding when adding a field through the UI is to initially name the field with what you want the internal name to be (usually something with no spaces), that way SharePoint will not add any special encoding to the internal name, and then after the fact you can go back and change the display name to be whatever you want. The field will retain the internal name it was given when initially created.

When creating CAML queries, if you use the Name attribute in your FieldRef, you should be using the internal name of the field. There is, however, the option of using an attribute DisplayName in order to reference the field by its display name. Source on MSDN.

Here are some other questions and answers on SP SE regarding the encoding of internal names and also some undocumented character limits on internal names.

ows_Hello_0x200_World - this looks to me like the name of the crawled property of the field. When the SharePoint search engine does it's indexing, it will create crawled properties with the name ows_FieldInternalName.

I do not know what the relationship is between SOAP responses and the crawled property name, perhaps the web services internally use the search engine to provide responses?

2
  • Thanks for the comprehensive quality answer. Still learning a lot about SharePoint internals; it strikes me as crazy to choose initial names for attributes so as to manipulate the internal name, with the plan of later changing it anyway, but based on how SharePoint actually works, I can see why this approach makes sense. Commented Apr 16, 2015 at 20:19
  • there is another one - SPField.StaticName. Most of the time its the same as InternalName.
    – dbardakov
    Commented Apr 17, 2015 at 15:13
1

What you are seeing is the internal name and the display name. These can be the same or different. When I am creating an application or anything custom where I will be using web services to fetch data, I carefully name my columns.

In the UI when you create a column like "My column" it gets set as My_0x200_column internally like you see and as ows_My_0x200_column in the web service results. However if you create it as Mycolumn, this will set the internal name as Mycolumn. It can then be edited to read My column. It will be returned in web services as ows_Mycolumn.

I use this technique to give short internal names I can easily reference in code and still give longer column titles as necessary. If developing in VS, you always have the ability to programmatically create the column and set separate internal and display names for the field.

2
  • Are you saying that you first name fields without a space to set the internal name, and then later edit to add the space so that the internal name stays clean? And if there are only two names (internal and display) then why in the XML response do so many attributes have ows_ prepended to them? Commented Apr 16, 2015 at 17:49
  • Correct, that is what i do. The ows is prepended as part of the web service response, you cannot reference that when trying to fetch data from the server. All SOAP queries to the server need the internal name and all XML responses from the server will contain ows. Commented Apr 16, 2015 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.