Created
July 15, 2015 12:56
-
-
Save wictorwilen/7b2f505ff3518d175bfa to your computer and use it in GitHub Desktop.
Remove Custom Action with JSOM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like this is the same as the AddCustomAction! Please check!