Create an app wich retrieve App list on a site collection/root site of a site collection

Hello,

how can i retrieve the app list of my rootsite of site my site collection using javascript?

I wanna create an app wich display all app installed and not installed on the site collection where my app is installed..

regards

July 2nd, 2013 7:47am

You can use the REST search api to get a list of all installed apps. Apps are basically sub sites which use the web template "APP". Your app will need to have the "Search - QueryAsUserIgnoreAppPrincipal" permission. The code below shows the REST syntax you could possibly use. To get a list of of apps that are in the catalog and not installed is probably not possible, especially in O365. In SharePoint you most likely will have to give users of your app full control of the site collection to see this list.

function doAppSearch() {

    var searchRestSource = decodeURIComponent(getQueryStringParameter("SPAppWebUrl")) + "/_api/search/query?querytext='"
       + "WebTemplate:APP'"
       + "&selectproperties='Path,Author,Title,LastModifiedTime'" 
       + "&rowlimit=500"
       + "&trimduplicates=false"
       + "&enablequeryrules=true"
    try {
        $.ajax(
                   {
                       url: searchRestSource,
                       method: "GET",
                       headers: {
                           "accept": "application/json; odata=verbose",
                       },
                       success: function (data) {
                           if (data.d.query.PrimaryQueryResult.RelevantResults.RowCount > 0) {
                               var queryResults = data.d.query.PrimaryQueryResult.RelevantResults.Table.Rows.results;
                           };                          
                       },
                       error: function (err) {
                           alert(JSON.stringify(err));
                       },
                   }
               );
    }
    catch (err) {
        alert(JSON.stringify(err));
    }
}

Free Windows Admin Tool Kit Click here and download it now
July 4th, 2013 2:11am

will it be sharepoint hosted apps or can it (also?) be provider hosted apps also to implement same functionality?
May 21st, 2015 2:56am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics