Skip to content

This Column Name is not What You Think – Be Careful With Column Names in SharePoint 2013 / Office 365

 

I’ve been involved with SharePoint for a very, very long time, since 2001 in fact. One of the basic truths that we old timers learned very early on was that an internal list column name wasn’t necessarily the same as its display name. For the most part, when a column is created, the name is the same, but any subsequent changes to the name only affect the way that it is displayed, and the original name stays the same. In fact, even on creation, if a space is used in the name, when saved, the internal name replaces the space with “_x0020_”. This is why it is a best practice to create all entities using no spaces, and then edit them later adding any desired spaces. It just makes life easier for people working with internal names.

Who works with internal names? Anyone that needs to extend SharePoint really. Any explicit reference to a SharePoint column normally needs its internal name. Given that display names are editable, this makes sense. Because of this, for a long time, I’ve gotten used to being careful about column names when creating them, so that it’s easy to reference them later.

Recently, I ran into a very odd behavioural change with SharePoint 2013 (Also with Office 365). My situation was that we needed to display a rotating banner on a page. I decided to use Marc Anderson’s SPServices to do the heavy lifting. Also, since I’m not that great at JQuery (or Javascript for that matter) I turned to Mark Rackley’s blog, who had an excellent example of an image slider using SPServices.

The way that the slider works is by reading entries from a custom list. This list contains a couple of columns named HTML and Picture. I added a third named DestinationURL to make the image clickable. I created this new list, and then edited it using the “traditional” method of accessing List settings. The HTML and DestinationURL fields were simple text fields, and the Picture field was a Picture column. Once created and populated, everything worked great.

Next up, I had to repeat this on a different site. I couldn’t save the custom list as a template because the destination site was in a different language. I therefore decided to just go ahead and create another list manually, but this time, I added the field with the new SharePoint 2013 “Quick List Editor”. If you haven’t seen it before, it shows up as a “+” symbol when you use it.image

image

You simply click the “+” symbol, choose the column type type the name of your column and keep going. If you choose the “More Column Types…” option, you are presented with the traditional column creation dialog box. I needed to use this for my “Picture” column.

image

Once complete, everything looked great.

image

I then went ahead and populated the list with content, and implemented the slider code on the home page. The trouble is that it wouldn’t work. After tearing out my hair a fair bit, it appeared that while the picture column was returning data, the HTML and DestinationURL columns were not. I found this very odd as I had been careful with the names, and this was a new list. Additionally, the Picture type column is more complex. If any column was going to give me grief, I’d think it’d be that one.

Finally, I decided to confirm the column names, because I don’t trust myself. The easiest way to do that is to go into List Settings, hover the mouse over the column definition, and check the destination URL that pops up as it contains “Field=fieldname” in it. I then did so for my HTML field:

image

What? The fieldname is “vtwo”. Upon checking, the DestinationURL field had an equally random name (“vn1m”). However, the Picture field was “Picture” as expected. How did this happen? Why did it happen to only two columns?

As it turns out, it’s the quick list editor is the culprit. When you add columns using it, it has no mechanism to check your column name against existing columns, so it doesn’t even try – it just forces a random column name. However, when you choose “More Column Types” it loads the traditional column editor, which does have such control, and therefore, my Picture field worked as expected.

After going back, deleting and recreating my two columns (and repopulating the content), everything worked as expected.

Lesson learned – when changing a list schema, stick to the list settings interface. Don’t use the Quick List Editor for adding new columns.

12 Comments

  1. John:

    This reminds me of that old chestnut:

    Patient: Doctor, doctor! It hurts me when I do this!
    Doctor: Then don’t do that.

    Good on you for using SPServices, even in a RESTful world. Who says its days are numbered? But why on earth did you go to Rackley’s blog instead of pinging me???

    M.

  2. I just ran into this issue yesterday myself. I wasn’t sure if it was the Quick List Editor or creating list columns in SharePoint Designer. Glad to know it’s not just me having these issues. Thanks for the post!

  3. Marc….. It’s all about SEO baby!! I don’t ask questions of very important people until I’ve thoroughly researched it myself…. I did want to use SPServices, and that’s actually how I came across Rackley’s post… search for SPServices and Slider. I did find an implementation on your site, but I think that Rackley’s was simpler. Still… if you have a better one, I’m all ears! 🙂

  4. Stefan Bauer Stefan Bauer

    Good to know that you have to be careful with this new feature. Right after you posted this article I have to try it myself and got the same result.

    For me the easiest ways to check the real name of a column is to check the source of a edit, display or new form.
    Right before the field control a html comment can be found that shows the internal and the display name of the newly created field that looks like this.

  5. Salman Salman

    Thank you John for this post. I am using a third-party web-part and it could not recognize the name of the column, but it was right there in front of me. Your trick about looking at the URL in List Settings revealed all. In 5 minutes, everything is working. Thank you again for helping out another fellow Canadian.

  6. Tuck Tuck

    Hi I am trying to implement this slider in my SharePoint 2013. I am running into this error .

    Failed to load resource: the server responded with a status of 400 (Bad Request)
    /_vti_bin/Lists.asmx

    Any idea what is causing it?

  7. John John

    THANK YOU! This has stumped me for days!!

  8. Yogesh Nandwana Yogesh Nandwana

    Thanks John, After reading in your blog about the way space is handled using “_x0020_”, it helped me to fetch values for fields(Created By,Modified By) and saved my time.Thanks a lot.

  9. Ben Ben

    Ahhhha.

    Thanks so much. Luckily, only an hour or so was wasted figuring out why name was random 🙂

    Appreciated!

  10. Zeki BERK Zeki BERK

    It has been 3 years since yo wrote this. But the bug is still there. Thanks it was very helpfull.

  11. Tyler Tyler

    This issue just hit us yesterday while trying to develop a CSOM connection with a SharePoint Online list. Thank you!

  12. jakub jakub

    Hi thanks! I tried to create PBI report taking as a source the SP list and had to fight with cross checking what that ‘xxxx’ column /had them 20/ really is, in order to put the right columns in the report . It sucks.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.