Skip to content

Instantly share code, notes, and snippets.

@wictorwilen
Created July 15, 2015 12:56
Show Gist options
  • Save wictorwilen/7b2f505ff3518d175bfa to your computer and use it in GitHub Desktop.
Save wictorwilen/7b2f505ff3518d175bfa to your computer and use it in GitHub Desktop.
Remove Custom Action with JSOM
var context = SP.ClientContext.get_current()
var web = context.get_web()
var actions = web.get_userCustomActions();
context.load(web)
context.load(actions)
context.executeQueryAsync(
function () {
var newAction = actions.add();
newAction.set_description('abc123')
newAction.set_location('ScriptLink')
var scriptBlock = 'var headID = document.getElementsByTagName("head")[0];var newScript = document.createElement("script");newScript.type = "text/javascript";newScript.src = "'
scriptBlock += web.get_url() + '/hqvglobalnavigation.js?ver=' + ((new Date()) * 1);
scriptBlock += '";headID.appendChild(newScript);';
newAction.set_scriptBlock(scriptBlock)
newAction.update()
context.executeQueryAsync(
function () {
console.log("Success")
},
function () {
console.log('Error')
})
},
function () {
console.log('Error')
})
@johnaagelv
Copy link

Looks like this is the same as the AddCustomAction! Please check!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment