0

Below is the code that I've currently got. I can not figure out how to add in the list view properly. I've added in var views = list.get_views("view name"); but every time I do, I get a blank page. Any help is appreciate, thank you.

$(document).ready(function () {
 ExecuteOrDelayUntilScriptLoaded(retrivetasklistitems, "sp.js");
  });
 var colltaskListItem;
 function retrivetasklistitems() {
 var clientContext = new SP.ClientContext.get_current();
 var oList = clientContext.get_web().get_lists().getByTitle('ContactInformation');
  var camlQuery = new SP.CamlQuery();
 colltaskListItem = oList.getItems(camlQuery);
 clientContext.load(colltaskListItem);
 clientContext.executeQueryAsync(Function.createDelegate(this, this.OnQuerySucceeded),
 Function.createDelegate(this, this.OnQueryFailed));
 }
 function OnQuerySucceeded(sender, args) {
 var listItemEnumerator = colltaskListItem.getEnumerator();
 var tasks = '';
 while (listItemEnumerator.moveNext()) {
 var oListItem = listItemEnumerator.get_current();
 var url = "https://URLURLURLURLURL/DispForm.aspx?ID=" + oListItem.get_item('ID');
 tasks += "<a href='" + url + "'>" + oListItem.get_item('Title') + "</a>" + "<br />";
  }
 $("#Ptask").html(tasks);
 }
 function OnQueryFailed(sender, args) {
  alert('Error: ' + args.get_message() + '\n' + args.get_stackTrace());
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.