Add Custom Action To List/Library Settings In SharePoint Using Visual Studio Feature And SharePoint Designer

Introduction

In this article, we will discuss, how to add Custom Action to List/Library Settings in SharePoint, using Visual Studio feature and SharePoint Designer.

Custom Action Overview

Customize SharePoint settings is for  if you want to extend the user interface. It is easy to do by using the List/Library settings. You can add new functionality to the SharePoint settings as custom actions. Custom actions enables you to expand or extend the standard behavior of SharePoint core components, such as using a custom action to the customized functionality of a list/ Library items.

This topic describes the two methods for adding a custom action to a List/Library settings of SharePoint. The custom action is added to the settings permission group.

You have two options to add the custom actions to a settings form:

  • Adding a custom action through SharePoint Visual Studio features. SharePoint features enables you to easily deploy the customizations.
  • Adding a custom action by using Microsoft SharePoint Designer. SharePoint Designer helps to create rapid, no-code customizations on the local Server.

Creating a Custom Action by Using SharePoint Feature

The following steps create a custom action in Visual Studio. The procedures in this section assume a development environment, where SharePoint is installed and configured. Microsoft Visual Studio is installed and the currently logged-in user has the administrative rights on SharePoint environment for the deployment purposes.

To Create a Custom Action by Using a Feature,

  1. In Visual Studio, click New Project, expand SharePoint node, click 2013 and then click Empty SharePoint Project. Name the project and then click OK.
  2. In SharePoint Customization Wizard, select the local SharePoint site, which can be used for debugging and whether the solution will be deployed as a sandboxed or farm.
  3. In Solution Explorer, right-click the Features node and click Add Feature.
  4. Name the feature and add a description
  5. In Solution Explorer, right-click the project, select Add and then select New Item.
  6. In Add New Item dialog box, select the Empty Element template, type the name and click Add.

    Add
  1. Open the Elements.xml file inside EmptyElement and then replace the file content with the code snippet, given below: 
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <Elements xmlns="http://schemas.microsoft.com/sharepoint/">  
  3. <CustomAction   
  4. Id="Custom.Configuration.ListCustomSettings"  
  5. GroupId="Permissions"  
  6. Location="Microsoft.SharePoint.ListEdit"  
  7. RequireSiteAdministrator="FALSE"  
  8. Sequence="100"  
  9. Title="Custom Action Settings">  
  10. <UrlAction  
  11. Url="javascript:window.location= '{SiteUrl}/_layouts/15/Portal/CustomActionPage.aspx?List={ListId}&Source=' + window.location"/>  
  12. </CustomAction>  
  13. </Elements>  

The CustomAction element defines the extension to the user interface and specifies the following attributes:

  • Description: Description of the custom action.
  • Title: The title of the custom action.
  • ID: Custom action unique identifier.
  • GroupId: Group under which the custom action occurred.
  • Location: Specifies the location of the custom action. For example, Microsoft.SharePoint.ListEdit will show this custom action on the Edit form of an item.
  • RegistrationId: Specifies the identifier of the list or item content type that this action is associated with.
  • Sequence: Specifies the ordering priority for the actions. A value of 0 indicates that the button will appear at the first position on the ribbon.
  • Rights: Specifies a set of the rights, which the user must have for the link to be visible. For example, ViewListItems indicates that a person with View List Items permission can access this custom action. If not specified, then the action always appears in the list of the actions.
  • ActionURL: On click of the settings link, where should we redirect.
  1. Save the file.
  2. Add the EmptyElement element to the feature, we created.
  3. Right click the solution name and then click Deploy. Visual Studio will build and deploy the solution to the farm.
  4. Navigate to the local site, add a custom list/library. Click List Settings/Library Settings.

    Settings
  1. The Settings page will open. We can see the custom action added to the settings under the permission group.

    Settings
  1. Click the Custom Action Settings link. It will take to CustomActionPage.ASPX with the parameter, as we set in ActionURL.

    ActionURL

Creating a Custom Action by Using SharePoint Designer

The following steps demonstrate adding a custom action by using SharePoint Designer. Ensure that SharePoint Designer is installed and that the currently logged-in user has the administrative rights in SharePoint environment.

To Create a Custom Action by Using the SharePoint Designer

  1. Start Microsoft SharePoint Designer.
  2. On the File menu, point to Sites and click Open Site.
  3. Type the URL of the local site such as http://siteURL.com and then click Open Site.
  4. In the Navigation pane, click the List and Libraries link and click the list name to which the custom action is to be added.

    List and Libraries

  5. Click Custom Action menu in the list settings section in the ribbon and then click menu to add the custom action.

    Custom Action

  6. In the Create Custom Action screen, type a name and description for the custom action.

  7. Type a URL in the Navigate to URL box.

    Navigate to URL

  8. Click OK.
  9. Open the site in the Browser, navigate to the list and then click on List Settings/Library Settings.

    Library Settings

  10. The Settings page will open. We can see the custom action added to the settings under the permission group.

    Settings

  11. Click Custom Action Settings link. It will take to CustomActionPage.ASPX with the parameter, as we set in ActionURL.

    ActionURL

Conclusion

Thus, you have learned, how to add custom action to List/Library Settings in SharePoint, using Visual Studio feature and SharePoint Designer.