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,
- In Visual Studio, click New Project, expand SharePoint node, click 2013 and then click Empty SharePoint Project. Name the project and then click OK.
- 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.
- In Solution Explorer, right-click the Features node and click Add Feature.
- Name the feature and add a description
- In Solution Explorer, right-click the project, select Add and then select New Item.
- In Add New Item dialog box, select the Empty Element template, type the name and click Add.
- Open the Elements.xml file inside EmptyElement and then replace the file content with the code snippet, given below:
- <?xml version="1.0" encoding="utf-8"?>
- <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
- <CustomAction
- Id="Custom.Configuration.ListCustomSettings"
- GroupId="Permissions"
- Location="Microsoft.SharePoint.ListEdit"
- RequireSiteAdministrator="FALSE"
- Sequence="100"
- Title="Custom Action Settings">
- <UrlAction
- Url="javascript:window.location= '{SiteUrl}/_layouts/15/Portal/CustomActionPage.aspx?List={ListId}&Source=' + window.location"/>
- </CustomAction>
- </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.
- Save the file.
- Add the EmptyElement element to the feature, we created.
- Right click the solution name and then click Deploy. Visual Studio will build and deploy the solution to the farm.
- Navigate to the local site, add a custom list/library. Click List Settings/Library Settings.
- The Settings page will open. We can see the custom action added to the settings under the permission group.
- Click the Custom Action Settings link. It will take to CustomActionPage.ASPX with the parameter, as we set in 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
- Start Microsoft SharePoint Designer.
- On the File menu, point to Sites and click Open Site.
- Type the URL of the local site such as http://siteURL.com and then click Open Site.
- In the Navigation pane, click the List and Libraries link and click the list name to which the custom action is to be added.
- Click Custom Action menu in the list settings section in the ribbon and then click menu to add the custom action.
- In the Create Custom Action screen, type a name and description for the custom action.
- Type a URL in the Navigate to URL box.
- Click OK.
- Open the site in the Browser, navigate to the list and then click on List Settings/Library Settings.
- The Settings page will open. We can see the custom action added to the settings under the permission group.
- Click Custom Action Settings link. It will take to CustomActionPage.ASPX with the parameter, as we set in ActionURL.
Conclusion
Thus, you have learned, how to add custom action to List/Library Settings in SharePoint, using Visual Studio feature and SharePoint Designer.