Wednesday, April 17, 2013

Custom Action Link in Site Settings – SharePoint 2010

SharePoint does not have an event handler firing on web updates. There are event receivers for WebMoving/ WebMoved, but they won’t fire on events like web title update. Therefore one option to perform some action after updating particular properties in web is to have a custom link in the site settings page of the web.

For example let’s say we want to update the titles for rest of the alternative language sites after changing the title of one of the webs. We can simply have a custom action in the site settings screen.


We can implement the action as clicking on this link will redirect the user to a _Layouts page where we have our custom code implemented to perform the required task.


This custom action can be created using an empty SharePoint element deployed by a feature.


Below is the elements.xml file for the Element. Here “GroupId” specifies the group in site settings page where the link should appear. Here is a list of the default custom action group IDs in MSDN. It is also possible to add a custom group in the site settings page. Here is the CustomActionGroup Element definition in MSDN. “UrlAction Url” specifies the _layouts page consisting of our custom code, while “Rights” specifies the set of rights that the user must have for the link to be visible. If this optional property is not specified, the action always appears in the list of actions.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <CustomAction
    Id="TitleAlternateLanguages"
    GroupId="Customization"
    Location="Microsoft.SharePoint.SiteSettings"
    Title="Title - Alternate Languages"
    Rights="ManageWeb"
    Sequence="41">
    <UrlAction Url="_layouts/AlternativeLanguages/prjaltlansetng.aspx"/>
  </CustomAction>

</Elements>

1 comment:

SharePoint Adam said...

You can create a visual studio solution which uses CustomAction for such requirements.

Here is the step by step instructions to build a visual studio solution which adds new custom link in site settings page: Add a Link to Site Settings Page in SharePoint.