Monthly Archives: February 2014

Custom site actions using JS in SharePoint 2013

Recently, moving to the cloud from on premises has been the talk of the town.

So, I decided to explore to move couple of my existing solutions or customization to be cloud ready.  One among them would be the modification of custom site actions in “Welcome” menu and “Site Actions” aka “Gear” control in SharePoint 2013.

The JS implementation would be like below:

<SharePoint:ScriptLink language=”javascript” name=”SP.js” runat=”server” LoadAfterUI=”true” />
<script type=”text/javascript”>

ExecuteOrDelayUntilScriptLoaded(retrieveWebSite, “sp.js”);

function retrieveWebSite() {
var clientContext = new SP.ClientContext.get_current();
this.oWebsite = clientContext.get_web();

var collUserCustomAction = oWebsite.get_userCustomActions();

var oUserCustomAction = collUserCustomAction.add();

oUserCustomAction.set_title(‘ECMA Website’);


clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

function onQuerySucceeded(sender, args) {alert(‘Custom action created for ‘ + this.oWebsite.get_title());}

function onQueryFailed(sender, args) {alert(‘Request failed. ‘ + args.get_message() + ‘\n’ + args.get_stackTrace());}


The same can be achieved for Welcome menu by making “PersonalActions” as the Group.

For the full list of Custom Action Locations and IDs, please refer –