I have simple JSOM script to get all the list and it's default view url but i am not getting default view url property

var context; 
var lists;

// This code runs when the DOM is ready and creates a context object which is needed  // to use the SharePoint object model $(document).ready(function () {

    context = SP.ClientContext.get_current();
    lists = context.get_web().get_lists();
    context.executeQueryAsync(function () { reqSuccess(); }, function () { reqFail(); });

function reqSuccess() {
    var listEnumerator = lists.getEnumerator();
    while (listEnumerator.moveNext()) {
        var list = listEnumerator.get_current();
        var listTitle = list.get_title();
        var listUrl = list.get_defaultViewUrl(); //Not getting this property
    } }

function reqFail(sender, args) {
    alert(args.get_message()); }

2 Answers 2


The syntax for loading Default View URL is below.


Default view is a valid list property and we need to explicitly load it.

  • 1
    you are right just but the syntax is little different context.load(lists, "Include(Title, DefaultViewUrl)");
    – SBP
    Oct 22, 2014 at 14:04
  • Thansk @SandipPatil, I have updated my answer. Oct 22, 2014 at 15:24

Since List.DefaultViewUrl property is not loaded by default you have to include it explicitly as demonstrated below:

var context = SP.ClientContext.get_current();
var lists = context.get_web().get_lists();
context.load(lists,"Include(Title, DefaultViewUrl)");
  function () { 
    var e = lists.getEnumerator();
    while (e.moveNext()) {
        var list = e.get_current();
        var listTitle = list.get_title();
        var listUrl = list.get_defaultViewUrl(); 

function logError(sender,args){

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.