Add custom action button in List ribbon using SharePoint designer 2013

This SharePoint designer tutorial, we will discuss how to add a custom action button using sharepoint designer 2013 into SharePoint 2013 list ribbon.

Also, we will see how to navigate to an URL, on click on the custom action button in SharePoint. I will also show how to get the selected item id, on click of the ribbon action button using SharePoint designer 2013.

We will also see how to call a JavaScript function, on click on a custom ribbon action button in SharePoint 2013/2016/Online.

The same way we can add a custom action button using designer in SharePoint 2013/2016/Online.

Add custom action button SharePoint designer

Follow below steps to add custom buttons to SharePoint list ribbon using SharePoint designer 2013

Open your SharePoint 2013 site using SharePoint designer 2013, then from the Site objects click on the Lists and Libraries from the navigation.

This will display all the lists and libraries in the page. Click on the particular list in which you want to add the button. Then from the List settings page, go to the ribbon click on Custom Action -> View Ribbon as shown in the fig below:

add custom action button sharepoint designer

This will open the Create Custom Action dialog box, Give a Name for the button and optionally put a description. Then in the Select the type of action there are three options to do:

  • Navigate to form: You can give the form name where you want to navigate.
  • Initiate workflow: You can initiate any workflow associated with the list by choosing this option.
  • Navigate to URL: You can specify the URL where you want to navigate on click on that button.

Here first we will choose to Navigate to URL option and give the URL like below:

Add custom action button in List ribbon using SharePoint designer 2013

Then in the Advanced custom action options, you can provide the Button image URLs and then in the Ribbon Location, you can provide the where the button will appear in the Ribbon. Here I have given the default option “Ribbon.ListItem.Actions.Controls._children“.

In this case, the button will appear in the list ribbon under the Items tab in the Actions section. see fig below:

how to add custom ribbon action on list/libraries in sharepoint 2013

You can check out SharePoint 2013 Ribbon Locations in this MSDN article.

Now once you click on OK in the Create Custom Action dialog box, then open the list in the browser, you will be able to see the button like below. Once you will click on the button you will be redirected to the provided URL presented in the Custom Action dialog box.

sharepoint custom action javascript

Open JavaScript Dialog box on custom action button click

You can open a JavaScript dialog box by writing the below line in the Navigate to URL in the Select the type of action:

javascript: alert('Hello World !!!');
sharepoint custom action ribbon location

You can also call any JavaScript function presented on the page. You can put the below code in a script editor web part in the List view page.

<script type="text/javascript">
function CallHello() {
alert ('Hello World !!!');
}
</script>

Then you can modify the Navigate to URL and can write like below:

javascript: CallHello();
command action sharepoint ribbon

Get Selected Item Ids on custom action button click

We can also get Ids of the selected items by using the below JavaScript code. Edit the page and then add a script editor web part into the page. Then insert the below JavaScript code:

<script type="text/javascript">
function GetItemId() {
var ctx = SP.ClientContext.get_current();
var items = SP.ListOperation.Selection.getSelectedItems(ctx);
var selectedItems = ";
for (index in items) {
alert (items[index].id);
}
}
</script>

Now modify the Navigate to URL option like below in the Create Custom Action dialog box.

javascript: GetItemId();

Now whenever the user selects one or more than one list item and then click on the custom ribbon button which we have just created, it will display the selected item ids in SharePoint.

You may like the following SharePoint designer tutorials:

Hope this SharePoint tutorial helps to add a custom action button using SharePoint designer 2013 in SharePoint 2013 list ribbon.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>