When calling more than one field the query fails. No descriptive reason why.

[Shorthand as typing on phone]

Working code:

 Function getData(){
    ctx = new SP.ClientContext();
    u = ctx.get_web().get_currentUser();
 Function Disp(){
 ...fail function, etc..

I can choose to have email or loginName output successfully however ctx.loadQueryAsync fails if I try both. Each of the following has been tested in place of previously used load:


Using any of the above result in a failed query. Message is Invalid Request a Microsoft.SharePoint.Client.InvalidQueryException. Other error values are undefined

2 Answers 2


Try the below code:

function getData(){
ctx = new SP.ClientContext();
this.u = ctx.get_web().get_currentUser();


 function Disp(){

} ...fail function, etc..

  • I receive error that the field has not been loaded. For now ive changed my code to run for one field at a time one after another
    – user13186
    Aug 4, 2015 at 17:24
  • try using this.u = ctx.get_web().get_currentUser();
    – Pushpendra
    Aug 4, 2015 at 17:29
  • I have tested and updated with working code.
    – Pushpendra
    Aug 4, 2015 at 18:24
  • This worked. Thank you! I won't forget this again
    – user13186
    Aug 4, 2015 at 18:59

Recently had to play with SharePoint JS and here is what I found (tested in SharePoint 2010), see code and comments, code is based on answer from here:

function getListInfo() {
    var context = SP.ClientContext.get_current();
    var web = context.get_web();
    var lists = web.get_lists();
    var list = lists.getByTitle('Test');

    context.load(list); // load all fields, seems slow
    //context.load(list, 'Id'); // load only 'Id'
    //context.load(list, 'Title'); // load only 'Title'
    //context.load(list, 'Id', 'Title'); // load only 'Id' and 'Title'
    //context.load(list, 'Include(Id, Title)'); // fails with 'Invalid request' message
    //context.load(list, 'Id', 'Title', 'Description'); // define each field to load as additional parameter
    //context.load(list, ['Id', 'Title', 'Description']); // dynamically define array with fields to load
    //var fields = ['Id', 'Title', 'Description'];
    //context.load(list, fields); // load fields defined in array variable

    context.executeQueryAsync(  //submit query to the server
        function () { //process result in success callback
            console.log('ID:' + list.get_id());
            console.log('Title:' + list.get_title()); 
            console.log('Description:' + list.get_description());
        function (sender, args) { //handle error in error callback

Alternatively you can try to use CAML query (see example here), in this case Include() works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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