Question: I hit an error where a field/property name wasn't available when trying to look up the value. The field was something like, `id` (or `Id` or `ID`) -- I forget. It would be great if I could programmatically display all the fields that might be used.

```
var ctx = SP.ClientContext.get_current();
var oDocumentSet = ctx.get_web().getFolderByServerRelativeUrl('/sites/<sitename>/Documents/<docsetname>');

ctx.load(oDocumentSet); // was also supplying 'id','Id','ID'
ctx.executeQueryAsync(
  Function.createDelegate(this, function(){
    // succeeded

    try {
      // Couldn't get any of the following to work:
      /*
        fields = oDocumentSet.get_listItemAllFields();
        fields.get_item('id');
        oDocumentSet.get_item('id');
      */

      // Would like to be able to see all the fields/items similar to the REST call:
      // https://<domain>/sites/<sitename>/_api/Web/GetFolderByServerRelativeUrl('/sites/<sitename>/Documents')/Folders('<docsetname>')/ListItemAllFields
    } 
    catch(e) {
      console.log('Error encountered:',e);
    }
  }),

  Function.createDelegate(this, function(){
    // failed placeholder
  })
);

```

Essentially, the REST call (submitted through the address bar) is showing properties that I'm not able to retrieve using JSOM/AJAX. Any help, pointers to some documentation is appreciated.

Answer: 
var context = new SP.ClientContext.get\_current();

var web = context.get\_web();

var list = web.get\_lists().getByTitle(listTitle);

// Use createAllItemsQuery to get items inside subfolders as well. Otherwise use new SP.CamlQuery() to get items from a single folder only

var query = SP.CamlQuery.createAllItemsQuery();

query.set\_folderServerRelativeUrl(folderServerRelativeUrl);
It was more an order of operation issue. Hopefully, this may help someone in the future:

```
var ctx = SP.ClientContext.get_current();
var oDocumentSet = ctx.get_web().getFolderByServerRelativeUrl('/sites/<sitename>/Documents/<docsetname>');

ctx.load(oDocumentSet, 'ListItemAllFields'); // could also include 'Properties' if needed
ctx.executeQueryAsync(function(){
    var fields = oDocumentSet.get_listItemAllFields();
    console.log( fields.get_fieldValues() );
  }), 
  function(){}
);

```

Note: I remove the `Function.createDelegate` from the answer to keep the answer a little more concise as it is good practice, but unnecessary.