Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 25064

Display "Active" Sites in Custom Site List using REST/jQuery

$
0
0

Hi all,

I am using the following to retrieve a list of sites, but would only like to retrieve the ones that have been marked as "active". I am using a custom list in each site with a site column named "Active" with a Yes/No field type. Is there a way to modify the following so that when it pulls the complete list of sub sites, it can cross check the custom list and field of "Active" to display what I am looking for? The actual display of sites is appended to a <div> with the ID of "MyProjects". Would this require nesting of ajax calls, and if so, how do I relate the two when the call below is at the Site Collection level and I am referencing a custom list within individual sites.

    $(document).ready(function ($) {
        var basePath = "https://yourcompany.com/sites/myprojects/_api/";
        $.ajax({
            url: basePath + "web/webs/?$select=title,url,effectivebasepermissions&$filter=effectivebasepermissions/high%20gt%2032",
            type: "GET",
            headers: { "Accept": "application/json;odata=verbose" },
            success: function (data) {
                //script to build UI HERE
                $.each(data.d.results,function(index,value){
                    $("#MyProjects").append("<p><a href=" + value.Url + ">" + value.Title + "</a></p>");                 
                });
            },
            error: function (data) {
                //output error HERE
                alert(data.statusText);          
            }
        });
    });


Personal Blog: http://thebitsthatbyte.com


Viewing all articles
Browse latest Browse all 25064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>