While debugging an issue I realized that SharePoint 2010 CSOM/JSOM does not return all fields if the list has too many fields. For example, the code below fails on a list. But if I delete one of the fields I created in the list then it works. If I re-create the field then the code fails again. In the example, I use the Editor
field but I do not think it is necessarily related to that field.
ExecuteOrDelayUntilScriptLoaded(function()
{
var context = new SP.ClientContext.get_current()
var list = context.get_web().get_lists().getByTitle("test");
var view = list.get_views().getByTitle("All Items");
context.load(view);
context.executeQueryAsync(Function.createDelegate(this, function(sender, args)
{
var query = new SP.CamlQuery();
query.set_viewXml("<View><Query>" + view.get_viewQuery() + "</Query></View>");
var items = list.getItems(query);
context.load(items);
context.executeQueryAsync(Function.createDelegate(this, function(sender, args)
{
var listEnumerator = items.getEnumerator();
while(listEnumerator.moveNext())
{
var listItem = listEnumerator.get_current();
var modifiedBy = listItem.get_item("Editor");
}
}), Function.createDelegate(this, function(){}));
}), Function.createDelegate(this, function(){}));
}, "sp.js");
I can not find ANYTHING that references this online. Does anyone know why this happens or how to force getting all fields regardless of how many fields are in the list?