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

Unable to read Document Name using Client Object model

$
0
0

Hi,

I am reading SharePoint document library using Java Script client object model.

I am trying to read the document name with title = oListItem.get_item('FileLeafRef');

I am unable to get the document Name, below is my code 

<script>
    var clientContext = new SP.ClientContext.get_current();
    this.web =  clientContext.get_web();
    clientContext.load(this.web);
        
    this.oList = web.get_lists().getByTitle('Project Deliverable Document Library');
    clientContext.load(this.oList);
    
    this.fields = this.oList.get_fields();
    clientContext.load(this.fields);
     
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml("<View Scope='RecursiveAll'></View>");
    this.collListItem = oList.getItems(camlQuery);
    this.currentUser = web.get_currentUser();       

    clientContext.load(this.collListItem); 
    clientContext.load(this.currentUser);
    clientContext.executeQueryAsync(onRequestSucceeded, onRequestFailed);
 
   function onRequestSucceeded() {   
  
   var title; 
   var oListItem;    
   var listItemEnumerator = collListItem.getEnumerator();   
   while (listItemEnumerator.moveNext()) {
     oListItem = listItemEnumerator.get_current();
       title = oListItem.get_item('FileLeafRef');
       alert(title);                  
   }
      
       
}function onRequestFailed(sender, args) {
    alert("Error While reading SharePoint List");
}
</script>


Viewing all articles
Browse latest Browse all 7589

Trending Articles



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