This post will help you whether you are building a site column, list column, or a library column. The behavior is the same across the boards and includes some sound best practices. We are going to look at changing the name of a column (in this case the Title column), as well as several ways to name your column. We will rate them from 1 – 3 (1 being the best practice while 3 is the worst practice). If you are creating columns just for use in SharePoint, then it may not be as big of a deal. You will definitely want to follow the best practices in the case where you are going to work with the Power Platform of M365, or the difficulty will increase exponentially.
Changing an existing column
As you may already know, it is possible to change the name of a column in SharePoint or SharePoint Online. When you do change the name visually it changes. That’s awesome! However, this does not change the actual field name in the back end, the database. It is just cosmetic only! As long as you understand this concept you are good to go. Look at Image 1 and see I changed the Title column name from Title to Tree Roots in the list for this blog post.
Image 1
This is great, however, when going into the M365 Power Platform, be sure to understand the field name is still Title! To show you, I have copied the last part of the URL for the now column I just renamed Tree Roots. You can see clearly, the field name for the column is still Title. I have changed the color of the text to red to assist with its visibility. You will need to know this and look out for it when working with the Power Platform. It may show Tree Roots in some instances, but many will require you to know the actual field name. After time passes, it could be a problem to remember if you changed the field name or not, so take good notes!
/_layouts/15/FldEdit.aspx?List=%7B0329FAE7-9402-42CF-A5E1-8A7A3FE51DAE%7D&Field=Title
The Behavior of Creating New Columns
Now to delve into column creation best practices for both SharePoint on premises and SharePoint Online. I have created four different columns using different techniques to name the column. They are mixed up in Image 2, but certainly show what I did to name the columns. I will go into an explanation for each one and show why they are a ‘best’ practice, ‘okay’ practice, or ‘do not use if you plan on using the Power Platform for your own sanity’s sake’ practice. (I know, that last one was a mouthful, but I am sure you get the idea.)
A Column Name Using CamelCase
Starting with the best practice and with the least amount of con’s we look at the column CamelCase. When you look at the tail of the URL to edit the column you can see the Field name is clean as you would expect. There are no extraneous characters added. This is just like having a one-word column name. It has the same effect. Just like the Title field URL above, this one is easy to read, and easy to understand. You can see as I highlighted the field for you in red.
/_layouts/15/FldEdit.aspx?List=%7B0329FAE7-9402-42CF-A5E1-8A7A3FE51DAE%7D&Field=CamelCase
A Column Name Using an Underscore
This is the second choice I would go with if I absolutely had to go with some sort of visual break in the column name. I would say this is an okay practice. The reason why I give it just an okay instead of a best practice is because each underscore in the field name will turn into the hexadecimal number %5F. Yeah, super memorable, right? When things get injected into the backend so that things don’t break in SQL, etc, that is something that can cause some discomfort in the Power Platform when you need to make reference to the column in question with this naming convention. See the area highlighted in red in the URL below so you can see what it actually looks like.
/_layouts/15/FldEdit.aspx?List=%7B0329FAE7-9402-42CF-A5E1-8A7A3FE51DAE%7D&Field=With%5FUnderscore
But wait! A short time after creating the List and letting things settle down, lo and behold, the URL changed to a nice beautiful, amazing work of art! Yes, no hexadecimal number and no nonsense. Long live the underscore! It is a clean field name easy to work with in the Power Platform on M365! I would dare say this has stepped from okay into the coveted best practice! So, if you create a list on the fly to feed data, capture data, or use in some way with the Power Platform, allow M365 time to do all the cleanup, etc. in the background so you have a nice field name to work with. If you don’t believe me, see below. It changed in the last 24 hours from creating the list.
/_layouts/15/FldEdit.aspx?List=%7B0329FAE7-9402-42CF-A5E1-8A7A3FE51DAE%7D&Field=With_Underscore
Columns Using a Space or a Dash (-)
These two columns fall in the worst practice as they have a mess added to the field name. When the list was first created it was even more of a nightmare as the underscores around the four-character indicator also contained the %5F. Fortunately, after the cleanup run in the backend over time, those did get changed to the actual underscore from the hexadecimal. Without the cleanup, the field name was nightmare fuel. Good thing I am posting this is during the Halloween season. Still take a look below at the URL’s. I will indicate which is which. These field names will prove troublesome when having to reference them in the Power Platform on M365.
With Space: /_layouts/15/FldEdit.aspx?List=%7B0329FAE7-9402-42CF-A5E1-8A7A3FE51DAE%7D&Field=With_x0020_Space
With Dash: /_layouts/15/FldEdit.aspx?List=%7B0329FAE7-9402-42CF-A5E1-8A7A3FE51DAE%7D&Field=With_x002d_Dash
I would use the space and/or dash sparingly when naming columns if you are not sure if you are going to use the Power Platform to draw information from the list/library you are adding the columns to.
Best Practices and Conclusion
As you can tell from the way this post was written, over time as things settled down, we have two Best Practices and two worst practices. The best practice to naming a column is to either use CamelCase or the Underscore (_). The worst practice to naming a column is to either use a space or a dash (-). As a simple way to conclude this post, here is a list of dos and don’ts.
- Do use an Underscore when naming a column.
- Do use CamelCase when naming a column.
- Do keep the column name meaningful.
- Do keep the column name brief.
- Use spaces when naming a column sparingly.
- Use dash (-) when naming a column sparingly.
- Do NOT try to write War and Peace for a column name.
- Do NOT EVER use an Asterisk (*) in a column. Never! See why on my post Keeping an Eye on the Risk in Asterisk