Whilst working on a project I received the following error when trying to add a column to a SharePoint list programmatically: “Column does not exist, It may have been deleted by another user.” This error appeared when the code was trying to add the column to the default view of the list.

The column had been added to the list which meant that the column did actually exist it just wasn’t being displayed in the view so I assumed the error was due to a typo. However after checking through the code I couldn’t see anything obvious that would be causing the error. I then noticed that the internal name of the new column did not match the one that I assigned to it in the code when I checked the column settings. The internal name should have been “SingleSourceJustificationRequired” however SharePoint had renamed this to “SingleSourceJustificationRequire” so the code was now looking for the wrong internal name. After some research I found that SharePoint sets a character limit for internal field names, the character limit is 32. I also found out that SharePoint will automatically change the internal field name if it exceeds this limit which was the problem in this case.

To prevent this error I deleted the column from the list and then recreated it in the code, changing the internal name so that it now matched this character limit. The column was then added to the list and the view without any errors.

Get Up To Speed With SharePoint 2019!

Download Our FREE eBook...

 

Download SharePoint 2019 eBook

Comments