Select Specific Lists

1

I have the following code to return the libraries of my project in SharePoint:

function retornarLista() {
    collList = website.get_lists();

    context.load(collList);//, 'Include(TemplateType==109)'
    context.executeQueryAsync(onQuerySucceeded, onQueryFailed);
}

function onQuerySucceeded() {
    var listInfo = '';
    var listEnumerator = collList.getEnumerator();

    while (listEnumerator.moveNext()) {
        var oList = listEnumerator.get_current();
        listInfo += 'Title: ' + oList.get_title() +
            ' ID: ' + oList.get_id().toString() + '\n';
        $("#biblioteca").append("<option value='" + oList.get_id().toString() + "'>" + oList.get_title() + "</option>");
    }
}

function onQueryFailed() {
    alert("Failed");
}

I would like to return only Image Libraries to transfer to a dropdown of select , but I have not been able to, can anyone help?

    
asked by anonymous 02.10.2014 / 17:58

1 answer

1

You are working with the SharePoint JCOM library. The definition of the list object for this library can be seen at this link:

link

Notice that there is a property called baseTemplate .

When you create a list, you are indicating its base template (by your comment, SP.ListTemplateType.pictureLibrary ).

Your code is almost complete, you only need to go through all the lists you got in the query and verify that the baseTemplate corresponds to the pictureLibrary template that you use to create them. When matching is because the list is an image library:)

editing to include code: Just adjust your code like this:

/* .. snip .. */
while (listEnumerator.moveNext()) {
    var oList = listEnumerator.get_current();
    if (oList.get_baseTemplate() == SP.ListTemplateType.pictureLibrary) { // Eis o pulo do gato.
        listInfo += oList.get_title() + '\n';
    }
    /* .. snip .. */
}

By the way this SP.ListTemplateType.pictureLibrary is a constant value, 109. Living and learning, I did not know this template ...

    
02.10.2014 / 18:27