0

I'm a Sharepoint App beginner. I have a SharePoint 2013 App that provisions List. How can I get the GUID of those list using CSOM and JavaScript?

Here's what I got so far:

    var lists;

    function getLists()
    {
        var context = SP.ClientContext.get_current();
        var web = context.get_web();
        context.load(web, "Title", "Description");
        lists = web.get_lists();
        context.load(lists, "Include(Id, Title, Hidden, ItemCount)");
        context.executeQueryAsync(onSuccess, onFail);
    }

    function onSuccess() {
        var ul = $("#listsList");
        var listsEnum = lists.getEnumerator();
        while (listsEnum.moveNext())
        {
            var list = listsEnum.get_current();
            if (list.get_hidden() == false )
            {                    
                var title = list.get_title();
                var elem = $("<li>" + title + " with GUID " + list.id  + "</li>");
                ul.append(elem); // append the details to a list
            }
        }
    }

    function onFail() {
        alert("Request failed");
    }

The list.id is always undefined. How do I access the GUID property, or am I doing something else wrong?

Thanks!

3

Try list.get_id().toString(); instead of list.id

| improve this answer | |

Your Answer

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

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