Sign up ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Is it possible to get list by url using ECMA script client model? For example something like this:


Please, refer to this correct answer on this question (for SP 2013 version only)

share|improve this question

3 Answers 3

There is no "get by URL" method for lists in the client object model that I am aware of.

About the closest thing you have is a GetFolderByServerRelativeUrl on the Web object:


Depending on what you want to do this might work for you...unfortunately you can't get the parent list from the folder object like you can in the .NET api.

share|improve this answer

If it is possible, you can use server insert like this:

context.get_web().get_lists().getById('<%= MyListId %>');

If you can't use server insert and JS is placed, for example, on DispForm.aspx - SharePoint ListProperty control can help:

context.get_web().get_lists().getByTitle('<SharePoint:ListProperty Property="Title" runat="server"/>');

Solution using only JS (without server insert and controls)

(Don't think it's the best solution) Get all list's in the web and iterate them to find one (or more) you need.

var lists = context.get_web().get_lists();
context.load(lists, 'Include(DefaultDisplayFormUrl)');
context.executeQueryAsync(function (sender, args) {
    var enumerator = lists.getEnumerator();
    while (enumerator.moveNext()) {
        var list = enumerator.get_current();

        if (list.get_defaultDisplayFormUrl().indexOf('Lists/MyList') != -1) {
                    // Get it
}, function(sender, args){ /*error*/});
share|improve this answer

For anyone in future, I wrote code that will do this (Note: this is managed client object model, re-write in JavaScript as appropriate).

listUrl is a WEB relative URL segment of the list, for example "Shared Documents".

Note I'm just setting this.listName here, but at that point you have the full List object, so grab whatever you need at that point.

        Folder folder = this.sharePointContext.Web.GetFolderByServerRelativeUrl(listUrl);
        ListCollection lists = this.sharePointContext.Web.Lists;

        this.sharePointContext.Load(lists, list => list.Include(l => l.RootFolder, l => l.Title));

        foreach (List list in lists)
            if (list.RootFolder.ServerRelativeUrl == folder.ServerRelativeUrl)
                this.listName = list.Title;
share|improve this answer
this is not a javascript solution – Mx. Aug 4 '14 at 13:01
Indeed (I found this in a fleeting search), but it wouldn't take much to re-write it to Javascript, only adding an async callback. All the objects are the same. – James Love Aug 4 '14 at 16:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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