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?
Thanks
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:
ctx.load(items,'Include(FileRef)');