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

add item to Site Actions menu in SharePoint online
InfoPath alternatives for form designing SharePoint

Here we will discuss how we can add site actions menu in SharePoint online Office 365 using JavaScript object model? We can add the below code inside a script editor web part which we can put inside a web part page.

Also you can read:
– SharePoint Online Office 365 Hide Browse and Page tab from page using css

– How to connect to SharePoint online site using SharePoint Online Management Shell?

– How to deploy WebJob to Microsoft Azure using Upload zip file method in SharePoint Online?

Below is the full code:

<script language=”javascript” type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js”></script>
<script language=”javascript” type=”text/javascript”>
$(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(“Go to EnjoySharePoint”);
menuAction.set_url(“https://www.enjoysharepoint.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>

Once we add the below code then we can see the menu options like below:

add item to Site Actions menu in SharePoint online
add item to Site Actions menu in SharePoint online

Hope this will be helpful.

Similar SharePoint 2013 Tutorials

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply