It throws error when I try to create and add column in list which contains special characters such as '&'.

I tried following:

DisplayName="a&b" Name="a&b" -------- throws error

DisplayName="a&amp ;b" Name="a&amp ;b" -------- throws error (remove space before';')

DisplayName="a&amp ;b" Name="a_x0026_b" -------- works fine (remove space before';')

Do I really need to convert special characters to their respective special codes for example '&' to 'x0026' ?

Is there any official document saying that ?

function addFields() {

        var clientContext = new SP.ClientContext.get_current();
        var oWebsite = clientContext.get_web();
        //Getting reference to the list
        oList = clientContext.get_web().get_lists().getByTitle('List1');

        var f2 = clientContext.castTo(
                    oList.get_fields().addFieldAsXml('<Field Type="Choice"  DisplayName="a&amp;b" Name="a&amp;b" />', true, 
        var choices = Array("Approved", "Rejected", "Progress");

            Function.createDelegate(this, this.onQuerySucceeded),
            Function.createDelegate(this, this.onQueryFailed)

    function onQuerySucceeded() {
        alert("List Field Updated");

    function onQueryFailed(sender, args) {
        alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

  • 1
  • 1
    And yes, you need to convert the file characters. – Christoffer Jul 10 '17 at 11:34
  • I have requirement that '&' must be supported in list's column name at-least in display name – codemirror Jul 10 '17 at 11:36
  • 1
    As long as you encode the internal column name (as long as it is not reserved by SharePoint), you should be able to set the display name to anything you want. – Christoffer Jul 10 '17 at 11:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.