SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to get all my custom fields from my list by Javascript Object Model..

The code I wrote down is this:

var items;
    $(document).ready(function () {
         var context = SP.ClientContext.get_current();
         var list = context.get_web().get_lists().getByTitle('Codice Ragione Sociale');
         var camlQuery = SP.CamlQuery.createAllItemsQuery();
         items = list.getItems(camlQuery, 'Ragione Sociale');


        context.executeQueryAsync(Function.createDelegate(this, onListDataSucceeded), Function.createDelegate(this, onListDataFailed));  

    function onListDataSucceeded(sender, args) {

        var listItemEnumerator = items.getEnumerator();

        while (listItemEnumerator.moveNext()) {
            var oListItem = listItemEnumerator.get_current();

            alert(oListItem.get_item('Title') + oListItem.get_item('Ragione Sociale'));


    function onListDataFailed(sender, args) {

        alert('List Data fetch failed. ' + args.get_message() + 'n' + args.get_stackTrace());

When I arrive on oListItem.get_Item('Ragione Sociale') system told me the column is not loaded... But I told the system to load it on getItems!

share|improve this question
Did you try Internal Name? :) – eirikb Sep 28 '12 at 11:01
eirikb's comment is likely the issue. You can determine the field's internal name by going to the properties page for the list, right clicking on the field, selecting properties and in the URL all the way at the end you will see Field=InternalName. Just remember that underscore is encoded in the URL as %5F so Field=Link%5Fx0020%5Fto%5Fx0020%5FTemplate is Field=Link_x0020_to_x0020_Template. See here:… – Robert Kaucher Sep 28 '12 at 12:34
A post on this subject [Good SharePoint JavaScript Client Object model use example for beginners][1] [1]… – Guy Perry Aug 13 '13 at 16:21
up vote 2 down vote accepted

In JavaScript, you specify Include as part of the query string that is passed to the load(clientObject) method in order to specify which properties to return. The following example uses this approach to return only the title and ID of each list in the collection.

 clientContext.load(collList, 'Include(Title, Id)');

If solution not work then please remove space in field name that may problem.

See this msdn post

share|improve this answer
Thank you! I use the Include and removed the space! Everything works fine ;) – Ziba Leah Sep 28 '12 at 13:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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