Custom actions in SharePoint 2013



In this post you will learn how to develop custom actions in SharePoint 2013. Custom actions are types of apps  experiences where you can develop and deploy them  for  ribbon control or  for menu item  to provide new functionality for lists or libraries in a host web to navigate to App web or App web to Host Web.

The coolest part of developing custom actions in SharePoint 2013 is developing these now becomes very simple compared to the previous versions of SharePoint. Using Visual studio 2012 the required code will get generated based on options you select in the wizard while developing custom actions.This makes SharePoint development easier compared to previous versions of SharePoint server.

In this post you will come to know about below two custom actions.

  • Ribbon custom action
  • Menu Item custom action

This post is a continuation of previous post post where you have developed a client webpart in SharePoint 2013.

I have created a guide on how to create custom action in SharePoint 2013, click the image below to download the guide.

Let's start building custom actions in SharePoint 2013.

Ribbon Custom Action:

To add ribbon custom action for the App projected which you have created, right click on the project [Add] [New Item] [Ribbon Custom Action] and enter the Name and click on Add button. It will start the wizard for creating custom action for Ribbon control.


Ribbon Custom action

In this wizard select host web where you want to expose the custom action. i.e. Your custom action will be available in host web.

The custom action scoped can be List template or List instance or None. In this example I am selecting List template and the  item is the custom action scoped to be "Custom list".

If you choose above options whenever you create a custom list for all those lists this Ribbon custom action will be available.

If you choose a custom action scoped as list instance then the item in the custom action scoped will be an individual artifact that you need select from the host web like list or library.

Once you have selected above options click on Next button.

Create Custom action for Ribbon

The below screenshot asks you where you want to show the custom action in Ribbon control. There are lots of options which you can choose, here I am selecting "Ribbon.ListItem.Actions". What this does is, it will show the custom action under Items section of List Ribbon control.


Create Custom action for Ribbon

You can give the name of the custom action in label text for the button control section. If you have multiple pages then you can choose one to which you want to navigate when user click on the custom action. Once you are done with all the settings click on finish. It will create the Ribbon custom action for you.


Create Custom action for Ribbon

You can see the below code snippet of elements.xml of ribbon custom action which will generate automatically for you based on your settings selected in the wizard.


Do you want to learn more about SharePoint Online Development? Click the image below and enroll in the FREE course.

After you deploy this along with your app project, create a custom list for example "Custom Ribbon action -testing".


custom List

Go to the Items section of Ribbon control, congratulations you can see the custom action you have added to ribbon control.


Testing Custom action for Ribbon

You can download the guide by clicking on the image below to develop Ribbon action menu

Menu Item Custom Action:

To add a menu item custom action to the App projected, right click on the project [Add] [New Item] [Menu Item Custom Action] and enter the Name and click on Add button. It will start the wizard for creating custom action for Menu Item.


Meni Item custom action

Select the host web to expose the custom action and choose a list template and custom list as custom action scope to then click on Next button.


Create Custom action for Menu Item

Enter the menu item text you want to show and page in App where you want to redirect when the user selects the Menu item then click on the Finish button.


Create Custom action for Menu Item

Below is a code snippet of the elements.xml file of Menu Item custom action which will generate automatically for you based on your settings selected in the wizard.


Deploy the Menu Item custom action, open the list which you have created and you can observe that new Menu Item appears under a menu item.


Testing Create Custom action for Menu Item

Conclusion:

In this post you have seen how to develop the custom action for Ribbon control and Menu Item using Visual Studio 2012 with the least amount of time and effort. So development becomes very easy with the release of Visual studio 2012 which certainly encourages more people towards SharePoint development.

You can check video here on Ribbon custom action in SharePoint server 2013.

Don't forget to download the guide to build custom action in SharePoint 2013.


Do you want to learn more about SharePoint Online Development? Click the image below and enroll in the FREE course.

› Custom Actions in SharePoint 2013



Join 6,500 subscribers and receive instant access to

Devendra's Library of Resources for SharePoint Developers

About Author

Devendra Velegandla is a four-time recipient of Microsoft's Most Valuable Professional (MVP) award (2014-2017) for Office Servers and Services MVP and  SharePoint Server. He received the MCC award for his contributions in Microsoft MSDN/TechNet forums. He loves sharing articles, videos, and tutorial on SharePoint and Office 365.