Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Does anyone knows how to show a custom action in the ribbon for only one list? At this moment I've got multiple custom lists, but my button is added on all of them. I only want to show it on one particular list...

(I found a simular question, but there isn't a good solution for it)

share|improve this question
add comment

2 Answers

up vote 10 down vote accepted

You can associate your custom action to a specific list by using the RegistrationId property.

Example:

<CustomAction ControlAssembly="MagicalProject.Actions" 
                ControlClass="MagicalProject.Actions" 
                ControlSrc="/_layouts/MagicalSite/MagicalPage.aspx" 
                Description="This is my custom action which does magical stuff" 
                GroupId="MyMagicalActions" 
                Id="f5bcd75e-23b9-4623-9a82-41cc7ceb10a6" 
                RegistrationId="MyMagicalList" // Or whatever other identifier you have for your lists
                RegistrationType="List" 
                RequireSiteAdministrator="false" 
                Rights="AddListItems" 
                Sequence="1" 
                ShowInReadOnlyContentTypes="false" 
                ShowInSealedContentTypes="false" 
                Title="MyCustomAction">

UPDATE: It also applies for ContentTypes. So if you associate it with a contenttype, then all lists inheriting that specific contenttype will also get this custom action. In case you wanted to know how to put it on more than 1 list.

All it takes is changing RegistrationType from List to ContentType

share|improve this answer
    
I've used as RegistrationId the Id from the list and than it worked perfectly. Thanks! –  Ruben Herman Jan 26 '12 at 9:50
    
Wasn't the registration id used to specifiy a list ServerTemplate id? You can associate the custom action to a specific template (es: generic list, document libray, image library ecc), but I don't think you can use the registration id to specify a string name of a list. –  SPArchaeologist Jan 26 '12 at 9:58
    
@SPArchaeologist According to MSDN you can. I think you might be thinking about RegistrationType. –  Daniel Ziga Jan 26 '12 at 10:02
    
@Dandroid. From my experience, the registration id is used to specify a list template id (you must also set the parameter RegistrationType to "List"). That way you can for associate your action with every list of a set template - be it Survey (102), GenericList (100), PictureLibrary (109) ecc ecc. I am not aware if you could also use a list name/url/other in place of the template id - I will test this when I get some time, for now this is a nice thing to know (that would open new way to implement things). –  SPArchaeologist Jan 26 '12 at 10:19
1  
@JohnDoDo: One more thing. I'm not sure I fully understood your situation, but if you need to add your custom action to a specific Content Type you may try to change the registration type to ContentType and set the RegistrationID to the id of your CT. –  SPArchaeologist Feb 3 '12 at 8:06
show 4 more comments

I've made some research on the subject of RegistrationId and RegistrationType according to declarative Ribbon customization. All my findings can be found here:

RegistrationType & RegistrationId in SharePoint 2010 declarative Ribbon customizations

As a short summary: You can use all four registration types to target some content for Ribbon customization.

And concerning your question: There's no direct option to specify single list instance by means of registrationid. But there's a workaround; you can create an unique content type for your specific list and use RegistrationType = ContentType to target it.

Another way you can go is the programmatic Ribbon customization.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.