This project has moved. For the latest updates, please go here.

$().SPServices.SPGetListItemsJson empty object properties

Oct 23, 2014 at 8:49 AM
I ran into an issue with SPGetListItemsJson

    currentUserCollectionsObj = $().SPServices.SPGetListItemsJson({
        webURL: $.fn.SPServices.defaults.webURL,
        listName: "{e8ba9a92-dfa4-4100-9f1e-087d7ca2f15f}",
        CAMLQuery: "somequery"
... returns only attributes which are shown on the default view of that list. If the column is not on the default view, the object property will be there, but it will be empty.

Is that intended behaviour? Did I do something wrong?
Oct 23, 2014 at 11:28 AM
That's exactly the expected behavior, if you read through the docs for the GetListItems operation. If you want to specify the fields to return (almost always a good idea, as the default view can change), specify them in the CAMLViewFields.

BTW, you don't need to use this:
webURL: $.fn.SPServices.defaults.webURL,
as SPServices will use the current site or the default value you have set.

You can also use the list name ("Announcements") rather than the GUID, for clarity. It also makes moving between sites or environments painless.