Wednesday, 26 April 2017

Query List/Document Library in Specific Folder

To query SharePoint List or Document Library in specific Folder “FolderServerRelativeUrl” as part of the CAML Query

Code Snippet

using (ClientContext clientContext = new ClientContext(siteURL))
{
List customList = clientContext.Web.Lists.GetByTitle("CustomListName");
CamlQuery camlQueryCustomList = new CamlQuery();
camlQueryCustomList.ViewXml = "<View Scope='RecursiveAll'><Query><Where><Eq><FieldRef Name='CustomField'/>" +
"<Value Type='Boolean'>1</Value></Eq></Where></Query></View>";
camlQueryCustom.FolderServerRelativeUrl = "/Lists/CustomListName/FolderName";
ListItemCollection items = customList.GetItems(camlQueryCustomList);
clientContext.Load(items);
clientContext.ExecuteQuery();
}

No comments:

Query List/Document Library in Specific Folder

To query SharePoint List or Document Library in specific Folder “ FolderServerRelativeUrl ” as part of the CAML Query Code Snippet ...