0

enter image description here

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
<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
    Can you provide some context/explanation ? – JayHell Jan 20 '16 at 15:40
  • 1
    You 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. – Christoffer Jan 20 '16 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.