I found some code on line, see below, and changed it to meet my needs but when I run it I get:

Due Date undefined

This is the only value in the list, but it should look like:

Due Date 01/31/2019

Below is the code. Also I'm not a coder, so if you answer please show me what to correct.

<table width="70%" align="left" id="myHTMLTable" border="1"> 
      <tr align="left"> 
      <tr align="middle"> 
         <td align="left">undefined</td> 
<script type="text/javascript">

getMyListData() ;

function getMyListData()
        var method = "GetListItems";                 
        var webURL =  $().SPServices.SPGetCurrentSite() ;                     
        var list = "Project Statement";                      
        var fieldsToRead = "<ViewFields>"+"<FieldRef Name='Name' />" +"</ViewFields>";
        var query = "<Query><OrderBy><FieldRef Name='Due-Date' /></OrderBy></Query>"; 

                    operation: method,
                    async: false, 
                    webURL: webURL,
                    listName: list,
                    CAMLViewFields: "<ViewFields Properties='True' />",
                    CAMLQuery: query,                                                                                     
                    completefunc: function (xData, Status)
                              var vDueDate = $(this).attr("ows_Due-Date");

                              $("#myHTMLTable").append("<tr align='middle'>" +
                               "<td align='left'>"+vDueDate+"</td>" + 


1 Answer 1


Make sure that you are using the internal field name correctly for the "Due Date" column.

I think it's not Due-Date so you got

an undefined error

To get the internal field name

  • Open list settings.
  • Below COlumns, Click on the column name.
  • Look at the URL, and check the Field Query String value.

    Ex:  &Field=Due_x0020_Date
  • In this case, the field internal name is Due_x0020_Date

Finally, in your code, update each Due Date occurrences with this internal field

var query = "<Query><OrderBy><FieldRef Name='Due_x0020_Date' /></OrderBy></Query>"; 

Also, I suggest using the U2U tool to get the internal name and build your CAML query in a correct manner

  • Got the date, but it looks like 2019-01-31 00:00:00. How do I change the format to look like: 31 January 2019? I've tried a few different formatting options that I found on line, but when I run them the date then does not show at all.
    – drcoz
    Commented Nov 16, 2018 at 14:38
  • Please close this question first by marking the answer as accepted, then ask this new question in independent question! Thanks! Commented Nov 16, 2018 at 15:30

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.