I am working on a solution where I am using JSOM, I got confused on to the usage of Include in when you load the items collection, and usage of to get which fields you want? What's the specific purpose of each one?


1 Answer 1


Both ViewFields query option and SP.ClientContext.load method allows to control the columns returned in result. The main difference that ViewFields query option also includes system columns. From another hand SP.ClientContext.load method allows to specify the columns strictly that will be included in result.


ViewFields query option

The following query:

<View><Query></Query><ViewFields><FieldRef Name="FileRef" /></ViewFields></View>

in addition to FileRef field, the fields such as ID, Modified, Editor and some another will be included in result.

SP.ClientContext.load method

The following method demonstrates how to include only FileRef field in result:



CAML and the Client Object Model

  • Hi Vadim, Thanks for your reply, when I used them together, I had to populate also the ViewFields with my fields, otherwise they won't appear in the query if I only use Include in the load function, I am confused about that. Oct 4, 2014 at 3:16
  • Richard, you are right,I missed it. To summarize: in order to select the list of specific fields both the ViewFields query option and fields names for SP.ClientContext.load method have to be specified. Oct 4, 2014 at 9:35
  • 1
    I would disagree, only the view fields need to be specified, if you omit the Include, it will still work, so why the need of the Include if I use viewfields?? Oct 4, 2014 at 14:16
  • 1
    If you specify ViewFields option, then also columns specified in ViewFields plus system columns will be returned in result. If, in addition to ViewFields option, you specify columns to retrieve in Load method, than only that columns will be returned in result. Oct 6, 2014 at 6:27

Your Answer

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

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