Showing posts with label add item to Site Actions menu in SharePoint online Office 365 using JavaScript object model. Show all posts
Showing posts with label add item to Site Actions menu in SharePoint online Office 365 using JavaScript object model. Show all posts

Sunday, 3 December 2017

add item to Site Actions menu in SharePoint online Office 365 using JavaScript object model

<script>
    $(document).ready(function () {
        SP.SOD.executeFunc('sp.js', 'SP.ClientContext', AddCustomMenuAction);
    });

    function AddCustomMenuAction() {

        var clientContext = new SP.ClientContext();
        var oWeb = clientContext.get_web();

        var menuActions = oWeb.get_userCustomActions();
        var menuAction = menuActions.add();
        menuAction.set_location('Microsoft.SharePoint.StandardMenu');
        menuAction.set_sequence(101);
        menuAction.set_group('SiteActions');
        menuAction.set_title("sharepoint-data.blogspot.com");
        menuAction.set_url("http://sharepoint-data.blogspot.com/");
        menuAction.update();

        clientContext.load(menuActions);
        clientContext.executeQueryAsync(OnSuccess, OnFailure);
    }

    function OnSuccess() {
        alert('Custom menu action added in site actions');
    }

    function OnFailure() {
        alert('Fail');
    }
</script>