In Gear Menu(Site Action Menu) i created custom Menu Using JavaScript CSOM. now i want to delete those Custom site action menus. so please let me show how i delete it.
1 Answer
<script Language="JavaScript">
_spBodyOnLoadFunctionNames.push("GetUserCustomActionSite");
var siteUrl = _spPageContextInfo.webAbsoluteUrl;
var collUserCustomAction;
var clientContext;
var oWebsite;
function GetUserCustomActionSite() {
clientContext = new SP.ClientContext(siteUrl);
oWebsite = clientContext.get_web();
collUserCustomAction = oWebsite.get_userCustomActions();
clientContext.load(oWebsite, 'Title', 'UserCustomActions');
clientContext.executeQueryAsync(DeleteCustomAction, OnQueryFailed);
}
function DeleteCustomAction()
{
var customActionEnumerator = collUserCustomAction.getEnumerator();
while (customActionEnumerator.moveNext())
{
var oUserCustomAction = customActionEnumerator.get_current();
if (oUserCustomAction.get_title() == 'ITSD Admin1')
{
oUserCustomAction.deleteObject();
clientContext.load(oUserCustomAction);
clientContext.executeQueryAsync(OnQuerySucceeded,OnQueryFailed);
}
}
}
function OnQuerySucceeded(sender, args) {
alert('Custom action deleted for ' + this.oWebsite.get_title());
}
function OnQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}
</script>
-
1
-
1You should clear some things up about your answer, otherwise it may be deleted. What does the code do? Where to put it? Simply pasting a piece of non formatted code won't help to much. Jan 20, 2016 at 15:55