I am working with SP.js to get data from a SharePoint library.
Below is the code i am using:
var clientContext = new SP.ClientContext();
var oList = clientContext.get_web().get_lists().getByTitle(listName);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View Scope="RecursiveAll"><Query><OrderBy><FieldRef Name="Title" /></OrderBy></Query></View>');
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceededLoad), Function.createDelegate(this, this.onQueryFailedLoad));
function onQuerySucceededLoad(sender, args) {
//alert("success");
var olistItemEnumerator = collListItem.getEnumerator();
var ocount = collListItem.get_count();
//alert(web.get_serverRelativeUrl());
if (ocount > 0) {
while (olistItemEnumerator.moveNext()) {
var oListItem = olistItemEnumerator.get_current();
var data = oListItem.get_data();
var path = oListItem.get_path();
otable.push({
otitle: oListItem.get_item('Title'),
ocapability: oListItem.get_item('Category'),
ourl: oListItem.get_item('Answer')
});
}
I am able to get field values but i am not able to create a URL which will point to the document. I want to create a download link.
Regards.