I am wondering if anyone could clarify my confusion on how to use JavaScript to read/filter SharePoint List items, please? As a code example from MSDN: https://msdn.microsoft.com/en-us/library/office/hh185007(v=office.14).aspx

In the CAML query XML, what is the FieldRef field in SharePoint List? Is it defined column names/list properties?

When ClientContext object load collListItem, it has a (Include) parameter which includes a bunch of field/property names, what are they? Are they defined column names/list properties as well?

Is there anyway I can know what field names are, so I can use/filter the List?

Thank you.


FieldRef (field reference) represents a reference to a field from list within a CAML query

Refer to: FieldRef Element (Query)

When preparing the CAML query, you obviously specify the fields you want to retrieve from the list.

Whenever querying using CAML it requires the internal name of the field (column), e.g. field name 'Created' have internal name 'Author', which should be used in query etc.

You can view the internal name by editing the field and looking in the browser address bar or by hovering the mouse over the column name in list settings.


FieldRef has several meanings, one is a reference to a field within a query, other is a column (field) to reference in specified content type.

Look here for specifications: FieldRef Element (Query) and here FieldRef Element (ContentType)

Here, in your example,

camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' + '<Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>');

FieldRef is a reference to a field (column) "ID" with type "Number".

But FieldRef is not a property of the list.

| improve this answer | |
  • Thank you. That helps a lot for me to understand where are the column names from in the "Include". Is FieldRef a property of the List as well? – Xiao Han Nov 16 '17 at 15:07
  • Updated my answer. Please accept my answer if you find it to be helpful. Optionally you can vote it up. – Sergey Nov 16 '17 at 19:59
  • When FileRef as a column(field), is there anyway, I can find out which column(field) it is referring to? Because when it has something like this: .load(newsitems, "Include(ID, Title, FileRef, NewsDate)"); I have no idea what FileRef means in here. Any suggestion? Thank you. – Xiao Han Nov 17 '17 at 19:45

I agreed with Sergey, FieldRef is the reference of list in list schema.

In ClientContext.Load with Include, it will make sure the item collection load with necessary field or properties in ClientContext. If you want to Filter the list with specific fields, it is necessary to get the field internal name, here is a JavaScript code will do the function:

<input type="text" id="ListName" value="Tasks"></input>
<button onclick='GetFieldList()'>Get Field List</button>

<script type="text/javascript">

function GetFieldList()
  var listname = document.getElementById("ListName").value;
  var ctx = SP.ClientContext.get_current();
  this.web = ctx.get_web();
  this.list = web.get_lists().getByTitle(listname);
  this.fields = this.list.get_fields();

  ctx.executeQueryAsync(Function.createDelegate(this, this.getListInfoSuccess), Function.createDelegate(this, this.getListInfoFail));

function getListInfoSuccess(sender, args) 
        var fieldEnumerator = this.fields.getEnumerator(); 
        var results="";
        while (fieldEnumerator.moveNext()) { 
            var oField = fieldEnumerator.get_current(); 
            if (!oField.get_hidden())
            results+= oField.get_title()
                + " - " + oField.get_internalName()
                + " - " + oField.get_hidden()
                + "\n";
function getListInfoFail(sender, args) 
 alert('Something failed. Error:'+args.get_message());    

| improve this answer | |
  • Thank you. I have the JavaScript code, but wants to understand the SharePoint part, which I can replace the parameter values with. – Xiao Han Nov 16 '17 at 16:18

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.