Monday, October 10, 2016

Sharepoint Add an app - Storefront javascript listtemplate modification

To display only ListTemplate that contains 'CG_', which can be customised as per your need. This script was added into masterpage using ScriptLink customactions javascript embed. 

The $2b_3 and $M_3 collection variables tend to change based on MS updates. You have to find the right one using browser devtools in your 'add an app page' to check the OOTB Storefront collection's and get the right ones.

//Function to hide OOTB apps in 'AddAnApp' page
function CGRefreshUI() {
            var listedApps = SP.Storefront.StorefrontApp.get_currentView();  
             //remove  Noteworthy
            listedApps.$2b_3.length = 0;
              //remove all except List templates starting with 'CG_'
                  for (var i = listedApps.$M_3.length-1; i--;) {
               if (listedApps.$M_3[i].$2R_0.Title.indexOf("CG_") < 0 ) {
                  listedApps.$M_3.splice(i, 1);

//Function check if SP.Storefront js is loaded and call core method
function CGAlterStorefront() {
        if (SP.Storefront != undefined) {                       
var listedApps = SP.Storefront.StorefrontApp.get_currentView();
if (listedApps == undefined || listedApps.$2b_3 == null || listedApps.$M_3 == null) { setTimeout(CGAlterStorefront, 300); return; }

//Call Alter 'Add an Apps/StoreFront' function


No comments:

Post a Comment