How to Write SharePoint Custom Actions

You create a SharePoint action to add custom buttons to the ribbon or settings pages. Actions can be created in Visual Studio and consist of a single Elements file. Multiple actions can be deployed with just one file. In typical SharePoint style, a web-level feature is used to install the action(s). 

Important AttributesWrite_SharePoint_Custom_Actions_by_Kayla_Funke_2.png

The appearance and functionality of your action is defined in Elements.xml using the CustomAction node as a base. This node has several common attributes that developers should be familiar with:


There are a variety of places developers can insert custom buttons and links. There are page ribbons, list ribbons, item ribbons, item context menus, list settings, site settings, etc. Specify this broad area with the Location attribute.


Within each ribbon or page, developers must also decide which control group they want their actions to reside in. They may choose an existing control group, or create a custom one. SharePoint provides a useful reference of all predefined locations and groups.


Sequence defines where the action will appear within a group. The lower the number, the closer to the front of the group the control will appear. Zero represents the first position. A good practice is to use numbers greater than or equal to 2000 to prevent custom actions from interfering with native controls. The best way to determine the correct sequence number is to experiment.

Registration Type and ID

If you wish to limit your action to a specific list or set of lists, you will need to include both RegistrationType and RegistrationId (one does not work without the other). Commonly used RegistrationTypes are List and ContentType.

For lists, RegistrationId should be equal to the base template identifier of the list (ex. 100 for GenericList, 101 for DocumentLibrary, 106 for Events, etc). This means you cannot use the List RegistrationType to target specific list instances, but rather categories of lists.

For content types, RegistrationId should be equal to a content type identifier, which contains information about each of its parent content types and follows this format:


Target Specific List or Library

If a developer must target a specific list, they should create a custom content type for that list alone, and point the action at that content type.

Target All Lists and Libraries

Developers commonly need to target all lists and libraries, no matter their template ID or content types. This is easy due to the hereditary nature of content type identifiers. Simply set RegistrationType to ContentType and RegistrationId to 0x. This is the system content type from which all lists and libraries inherit.


Set this to a SharePoint base permission in order to control who may see your custom action and who may not. For example, if a custom action provides additional control over a list, you may want to set Rights to ManageLists so that only admins with the ability to create and delete lists may see it.

Basic Setup

Setup custom action in How to Write SharePoint Custom actions blog post by Kayla Funke at Easy DynamicsThe initial setup for a custom action is simple:

  1. Create an empty SharePoint 2010 or 2013 farm project.
  2. Add an Empty Element to the project. Visual Studio will automatically add a web-level feature for you.
  3. Add a CustomAction node to your Elements file and flesh it out.

List Settings Action

To deploy an extra link to a list settings page, use the Microsoft.SharePoint.ListEdit Location and choose from Groups like GeneralSettings and Permissions.

Most of the time, you will want the link to direct to a custom application page. Use the UrlAction node to describe this behavior. You may include JavaScript in the Url attribute of this node. SharePoint will also automatically fill in special tokens like {ListId} to help your custom page identify the context of the request. If needed, leverage _spPageContextInfo, a useful SP JS global variable, to include current SPWeb information.

<CustomAction Id="CustomActionDemo.ListSettingsAction"
    Title="My Custom Settings"
    <UrlAction Url=" + '/_layouts/Custom_Settings/ListSettings.aspx?ListId={ListId}');" />

list settings in How to Write SharePoint Custom actions blog post by Kayla Funke at Easy Dynamics

Site Settings Action

To deploy an extra link to the site settings page, use the above example as a base. Change Location to Microsoft.SharePoint.SiteSettings and choose from several groups like SiteAdministration and SiteCollectionAdmin.

List Item and Document Actions

Adding a custom button to the ribbon for list items and documents is more complicated. Multiple actions are usually required in order to display the new button everywhere it may be needed—the display form, the edit form,{{cta(‘d173b5b6-18d9-4d5d-9383-d06f0cfdfa78′,’justifyright’)}} the create form, the list view, etc.

A different format is needed in order to add a button to the ribbon of any of the above pages. Start with an action for the CommandUI.Ribbon Location. Add a CommandUIDefinition node for each form you wish the button to appear on, and a corresponding CommandUIHandler to describe what should happen when the button is clicked.

Below is an example of adding a button (icon included) to both the list view and the display form of all generic lists:


                <Button Id="CustomActionDemo.ListViewAction"
                    LabelText="My Custom Settings"
                    Description="Edit custom settings for this list item."
                    Alt="Custom Settings"
                    TemplateAlias="o1" />
                <Button Id="CustomActionDemo.DisplayFormAction"
                    LabelText="My Custom Settings"
                    Description="Edit custom settings for this list item."
                    Alt="Custom Settings" 
                    TemplateAlias="o1" />


                CommandAction=" + '/_layouts/Custom_Settings/ListSettings.aspx?ListId={ListId}&amp;ItemId={SelectedItemId}');"
                EnabledScript="javascript:SP.ListOperation.Selection.getSelectedItems().length == 1" />
                CommandAction=" + '/_layouts/Custom_Settings/ListSettings.aspx?ListId={ListId}&amp;ItemId={ItemId}');" /> 

The CommandUIHandler for ListViewAction needs to do a little extra work. The button should only be enabled if a single list item is selected. Lucky for us, we can use JavaScript to determine this by providing the EnabledScript attribute with the following condition:

SP.ListOperation.Selection.getSelectedItems().length == 1

This is what ListViewAction will look like if you install it:

list view action installation in How to Write SharePoint Custom actions blog post by Kayla Funke at Easy Dynamics

And this is what DisplayFormAction will look like:

display form action installation in How to Write SharePoint Custom actions blog post by Kayla Funke at Easy Dynamics


Note that the ListViewAction will only work for items in a list due to the Location it uses. If you wish to target documents in a library instead, substitute the location of Ribbon.ListItem.Manage.Controls._children with Ribbon.Documents.Manage.Controls._children and update RegistrationId. The definition will otherwise remain the same. DisplayFormAction will work for both documents and items.

Context Menu Action

A context menu appears when you click on the down arrow beside the Title or equivalent column of a list or library. You can add custom actions to this menu as well. Below is an example of a context menu action applied to all lists and libraries.

    Title="My Custom Settings"
    Description="Edit Custom Settings for this list item."
    <UrlAction Url=" + '/_layouts/Custom_Settings/ListSettings.aspx?ListId={ListId}&amp;ItemId={ItemId}');" />

context menu in How to Write SharePoint Custom actions blog post by Kayla Funke at Easy Dynamics

What other tips on writing custom SharePoint actions have been helpful in your daily work? Share your wisdom with us in a comment below!

Found this blog post useful? Make yourself comfortable and check out our blog home page to explore other technologies we use on a daily basis and the fixes we’ve solved in our day to day work. To make your life easier, subscribe to our blog to get instant updates sent straight to your inbox:


847 thoughts on “How to Write SharePoint Custom Actions”

  1. If some one desires to be updated with most up-to-date technologies afterward he must be pay a visit this website and
    be up to date every day.

  2. Amman Arab university is a Jordanian educational institute of progressive education, located on Jordan Street, Mubis-Amman. Amman Arab
    college circles (AAU) was founded in 1997 under the difficult
    Education Council No. (1476) on 24/11/1997 as a non-profit private
    the academy specialized in graduate studies under the read out Amman Arab university circles for Graduate Studies, and thereby became the first college circles
    in Jordan that offers graduate programs leading to
    Master’s Degrees, and Doctoral Degrees. on 30/9/1998 the
    well ahead Education Council gave consent for the the academy to
    begin lively subsequently the pure No. (1625). Academic operation started in the beginning of the
    Second Semester of the academic year 1999/2000. One
    of Jordanian Private Universites

  3. A fascinating dіscussion is worth comment.
    I think that you shоuld publish more on this subject,
    it maү not be a taboо subject but generally folks don’t talk about tһese
    topics. To the next! Cheers!!

    Feel free to surf to my web blog – Terrazzo

  4. Good dɑy! This is my first vіsit tⲟ your blog!

    We are a team of volunteers and stɑrting a
    new project in a community in the same niche. Yoսr blog provided us useful information to work оn. You
    have done a extraordinary job!

    Feel free to visit my web-site – lempengan marmer

  5. Howdy! I could have sworn I’ve been to this website before but after browsing through some of the post I realized it’s new
    to me. Anyhow, I’m definitely glad I found it and I’ll be bookmarking
    and checking back often!

  6. Simply want to say your article is as surprising.
    The clarity in your post is simply spectacular and i could assume you’re an expert on this subject.
    Well with your permission let me to grab your RSS feed to keep up to date with
    forthcoming post. Thanks a million and please continue the rewarding work.

  7. Aw, tһis was a reаlly good post. Spending sоme timе and actual
    effort tо maкe ɑ very good article… but ѡһat cаn I say… I put things ⲟff a ᴡhole lot and don’t seem tо get ɑnything

    ᒪook іnto my ⲣage; Vclubshop

  8. I am no longer positive where you are getting your info,
    however good topic. I must spend a while studying more or figuring out more.

    Thanks for great information I was on the lookout for this information for my mission.

  9. Great blog here! Also your site loads up very fast!

    What web host are you using? Can I get your affiliate link to your host?
    I wish my web site loaded up as fast as yours

  10. I’ve been exploring for a little for any high quality articles
    or weblog posts on this sort of area . Exploring in Yahoo I
    eventually stumbled upon this website. Reading this
    information So i’m glad to convey that I’ve an incredibly excellent uncanny feeling I discovered just what I needed.
    I such a lot definitely will make certain to do not fail to
    remember this site and provides it a glance
    on a constant basis.

  11. Very good blog! Do you have any tips and hints for aspiring writers?
    I’m planning to start my own website soon but I’m a little
    lost on everything. Would you suggest starting with a free platform like WordPress or go for a paid option? There are so many options out there
    that I’m completely confused .. Any tips? Thank you!

  12. I know this if off topic but I’m looking into starting my own weblog and was wondering what all is needed to get set up?
    I’m assuming having a blog like yours would cost a pretty penny?
    I’m not very web smart so I’m not 100% sure.

    Any tips or advice would be greatly appreciated.

  13. I’m now not sure where you’re getting your info, however good topic.
    I must spend some time finding out more or figuring out more.
    Thank you for great info I was looking for this information for my mission.

  14. Have you ever considered publishing an e-book or guest authoring on other websites?
    I have a blog centered on the same ideas you discuss and
    would love to have you share some stories/information. I know
    my viewers would appreciate your work. If you are even remotely interested, feel free to send me an e-mail.

  15. Greate article. Keep posting such kind of info on your site.
    Im really impressed by your blog.
    Hey there, You’ve performed a fantastic job. I will certainly digg it and in my opinion recommend
    to my friends. I am sure they’ll be benefited from this website.

  16. That is among the most popular games of this kind. When you haven’t tried using it but, you’re lacking out! Do this recreation at no cost and see on your own. You gained’t be let down. Keep reading to understand what can make this activity so Particular

  17. Grow your understanding. Irrespective of whether you’re a newbie looking to outline an marketplace time period or a professional in search of strategic guidance, there’s an posting for everyone.|Dan jika sesuatu yang tidak diharapkan terjadi maka Anda bisa tenang karena sudah ada jaminan Asuransi dan juga garansi penjual.|As only one case in point, smart contracts could eliminate the so-called procure-to-spend gaps. When a product comes and it is scanned in a warehouse, a smart contract could straight away cause requests to the needed approvals and, after attained, immediately transfer cash from the customer to the vendor.

  18. hi!,I love your writing so so much! proportion we keep up a correspondence more about your post on AOL? I need an expert in this house to unravel my problem. Maybe that’s you! Having a look forward to see you. |

  19. I’m impressed, Ι muѕt ѕay. Seldom dօ I encounter a blog tһat’ѕ bоth equally educative ɑnd
    engaging, аnd without a doubt, you hаve hit the nail on tһe head.
    The issue is ѕomething ѡhich not enough men and women aгe speaking intelligently аbout.

    I am very haрpy I stumbled ɑcross tһiѕ in mу search
    foг something regɑrding this.

    My web page order cheap zoloft online

  20. The very heart of your writing whilst appearing agreeable at first, did not really sit properly with me after some time. Someplace throughout the paragraphs you were able to make me a believer but only for a short while. I nevertheless have got a problem with your leaps in assumptions and one would do nicely to help fill in those gaps. If you actually can accomplish that, I will certainly be impressed.

  21. Mаy I simply just say whаt a relief to uncover ѕomebody that
    reallү understands what tһey’re discussing oᴠеr thе
    internet. You ɑctually understand how to bring аn issue t᧐ light and mаke it impoгtant.
    Mߋre people need to ⅼook at thіs and understand
    tһis side of tһe story. It’ѕ surprising you’re not more popular since yoս surely hɑve thе gift.

    Take a ⅼook аt my web site buying cheap zoloft for sale

  22. Hi there, You have done a great job. I will certainly digg it and personally suggest to my friends.

    I am confident they will be benefited from this

  23. I still highly recommend it and reaching out to find aftercare, inpatient,
    or outpatient programs if needed. The resources and tools are there for you, now it is up to you to make the life

  24. Hі there! where ϲan i buy cheap cephalexin pill ( jᥙѕt wanted tօ ask if you ever have any ⲣroblems wіtһ hackers?
    Мy ⅼast blog (wordpress) ԝas hacked ɑnd I ended ᥙр losing mɑny mοnths of һard wⲟrk Ԁue to no data backup.
    Ꭰo yⲟu have ɑny solutions to protect ɑgainst hackers?

  25. How does a hair dryer generate such a powerful gust of air in the primary place?
    Protective screens – When air is drawn into the hair dryer because the
    fan blades flip, different things outdoors the hair dryer are additionally pulled toward the air
    intake. Next time you and pop watch a film, this may make issues a lot easier.
    The extra occasions your weblog readers click on these advertisements,
    the extra money you may make by way of the advert service.
    This text discusses a quantity of ways to earn money
    on the web. If you are trying to make a quick buck, your best bet is to sell
    something or issues your own that are of value. Those critiques – and the
    way in which firms handle them – could make or break an enterprise.
    If your portable CD player has an AC enter, you may plug
    one end of the adapter into your portable player and the opposite end into
    your car’s cigarette lighter and you’ve got a energy provide.
    This fully alerts you, the reader, to the likelihood that in the next paragraph you’ll learn the main twist in the
    argument put forth, making it entirely doable that you’re going to haven’t
    any curiosity in reading additional.

    Feel free to surf to my web-site …