Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

I need to get all files and file properties from a document library using javaScript

$
0
0

Below is my code. I am able to get the file name and modified date.. I need to get the files' paths, the modified by field, and files metadata (some of which are lookup fields).

var ListName = 'My Documents';
            var ctx = SP.ClientContext.get_current();
            var list = ctx.get_web().get_lists().getByTitle(ListName);                              
            var caml = SP.CamlQuery.createAllItemsQuery();
            caml.set_viewXml("<View><Query></Query><RowLimit>500</RowLimit></View>");
           allitems = list.getItems(caml);
            ctx.load(allitems);
            
            ctx.executeQueryAsync(Function.createDelegate(this, this.onDocumentsSucceededCallback), Function.createDelegate(this, this.onDocumentsFailedCallback));

function onDocumentsSucceededCallback(sender, args) { 

var ListEnumerator = this.allitems.getEnumerator();

while (ListEnumerator.moveNext()) {
               alert('items are being picked up');
                var listItem = ListEnumerator.get_current();
               //  alert('file name is: '); alert(listItem.get_item().get_file());
               //  var file = listItem.get_file();
                 alert(listItem.get_item('FileLeafRef'));
               // alert(listItem.get_item('Modified'));
              // alert(listItem.get_item('Modified By'));

}
}


faye fouladi



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>