Thursday, July 16, 2015

Fetching Data from Sub folder SharePoint

function start() {
 clientContext = new SP.ClientContext.get_current();
         web = clientContext.get_web();
         site = clientContext.get_site();
         clientContext.load(web);        
         clientContext.load(site);
         spListobj = web.get_lists().getByTitle("Shared Documents");

         var spCamlQuery = new SP.CamlQuery();
         spCamlQuery.ViewAttributes = "Scope=\"RecursiveAll\"";
         spCamlQuery.set_viewXml('<View Scope="RecursiveAll"><Query></Query></View>');
         spListobjItems = spListobj.getItems(spCamlQuery);
         clientContext.load(spListobjItems);
         clientContext.executeQueryAsync(Function.createDelegate(this, this.retrieveListItems), Function.createDelegate(this, this.onQueryFailed));

}


TO Fetch only Folder Names

         var query = "<Where><Eq><FieldRef Name='FSObjType'/><Value Type='Lookup'>1</Value></Eq></Where>";

No comments:

Post a Comment