Quantcast
Channel: Developing Apps for SharePoint 2013 forum
Viewing all articles
Browse latest Browse all 8089

How to Retrive the document in the document library.

$
0
0

Hi all,

i've made this code to retrive  the document in the document library, but there is a problem in the retrive of the context

if i put  var clientContext = new SP.ClientContext.get_current(); 

it doesn't find the'document' and if i put  var clientContext =new SP.ClientContext('/sites/DevNKH');

it returns null

How can i fix this problem ?

is that  a right of access that the user (me) does not have?

This is all the code:

function retrieveListItems() {

      //var clientContext = new SP.ClientContext.get_current();

      var clientContext =new SP.ClientContext('/sites/DevNKH');

      var oList = clientContext.get_web().get_lists().getByTitle('Documents');

      this.collListItem = oList.getItemById(2);

       clientContext.load(collListItem);

       clientContext.executeQueryAsync(

           Function.createDelegate(this,this.onQuerySucceeded),

           Function.createDelegate(this,this.onQueryFailed)

       );

   }

   function onQuerySucceeded(sender, args) {

      var listItemInfo ='';

      var listItemEnumerator = collListItem.getEnumerator();

      while (listItemEnumerator.moveNext()) {

          var oListItem = listItemEnumerator.get_current();

           listItemInfo +='\nID: '+ oListItem.get_id() +

              '\nTitle: '+ oListItem.get_item('Title')+

              '\nBody: '+ oListItem.get_item('Body');

       }

       alert(listItemInfo.toString());

   }

   function onQueryFailed(sender, args) {

       alert('Request failed. '+ args.get_message()+'\n'+ args.get_stackTrace());

   }

Thanks for helping me :)




Viewing all articles
Browse latest Browse all 8089

Trending Articles



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