Custom Action on Addanapp.aspx not executing

New Contributor

Hey all,


I've started to try and understand Scriptlink Custom Actions and as a bit of a test, I want to hide some elements on the addanapp.aspx page. 


Individually, I have managed to test each line of the elements in a Browser Developer Tools session and they hide as expected when executed individually. However, none of them are firing when I reference the following code from my Custom Action JS file.


Am I missing something obvious?


// Is MDS enabled?
if ("undefined" != typeof g_MinimalDownload && g_MinimalDownload && (window.location.pathname.toLowerCase()).endsWith("/_layouts/15/start.aspx") && "undefined" != typeof asyncDeltaManager) {
// Register script for MDS if possible
RegisterModuleInit("hideAddanApp.js", JavaScript_Embed); //MDS registration
JavaScript_Embed(); //non MDS run
} else {

function JavaScript_Embed() {

loadScript(jQuery, function () {
$(document).ready(function () {
SP.SOD.executeOrDelayUntilScriptLoaded(function () { SetStatusBar(message); }, 'sp.js');
// Customize the addanapp.aspx page
if (IsOnPage("addanapp.aspx")) {
//hide the search apps field and label

function SetStatusBar(message) {
var strStatusID = SP.UI.Status.addStatus("Information : ", message, true);
SP.UI.Status.setStatusPriColor(strStatusID, "yellow");

function IsOnPage(pageName) {
if (window.location.href.toLowerCase().indexOf(pageName.toLowerCase()) > -1) {
return true;
} else {
return false;


0 Replies