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

I wonder is there any ability to set not only one but multiple values of RegistrationId in CustomAction tag.

I have an elements.xml entry like this:

<CustomAction
Id="ClassifyDialogButton.SharePoint.Ribbon.CustomTab"
Location="CommandUI.Ribbon"    
Rights="EditListItems"
RegistrationType="List"    
RegistrationId="101">

Does anyone know how should I modify it to add another two RegistrationIds?

share|improve this question
    
I used the following approach and it work for most lists [How do you create a ribbon button custom action that will appear on all kinds of lists][1] [1]: sharepoint.stackexchange.com/questions/6158/… –  rob.alarcon Feb 2 '13 at 1:41
    
I used the following approach and it work for most lists [How do you create a ribbon button custom action that will appear on all kinds of lists][1] [1]: sharepoint.stackexchange.com/questions/6158/… –  rob.alarcon Feb 2 '13 at 1:42

3 Answers 3

up vote 2 down vote accepted

As a general rule, XML attributes aren't designed to have more than one value.

Interestingly, the attribute seems to be optional, so it may be possible to apply it to a great many places at once by leaving it out (probably too many).

My only other suggestion would be to do a good old fashioned copy-paste and have one CustomAction element for each RegistrationId needed.

share|improve this answer
1  
Yep, you can pass both RegistrationId & RegistrationType over, and this will apply your ribbon modifications on all the lists. –  Andrey Markeev Apr 15 '11 at 22:32
    
@omlin: I tried this approach, if RegistrationId and RegistrationType omitted then my tab doesn't show up anywhere. –  Dmitriy Inozemtsev Apr 18 '11 at 10:12
    
@MrBubbles: How about if you just omit RegistrationId? –  Stuart Pegg Apr 18 '11 at 10:17
    
@Stuart Pegg: Tried to solve problem in this way too. But got the same situation: the tab simply doesn't show up. –  Dmitriy Inozemtsev Apr 18 '11 at 13:52
    
@MrBubbles: Looks like either copy & paste or @omlins alternative answer are the way to go, then. –  Stuart Pegg Apr 18 '11 at 13:56

What you're really looking for, is SharePoint 2010 Fluent Ribbon API. It is a Codeplex project, which simplifies work with ribbon. It has in-depth documentation, including huge amount of samples and screenshots.

The only bad thing about this solution, is that you should rewrite your XML ribbon definition to FluentRibbon ribbon definition. But code definitions are much more flexible, and also FluentRibbon provides some extra features: simplified syntax, full-length documentation and qualitative validation, so IMO, it's worth it.

In your case, the resulting code will look like this (inside feature receiver class, in FeatureActivated method):

var myTab = new TabDefinition
{
    Id = "MyTab",
    Title = "My tab",

    // etc, create your definition here...
};

// instantiate RibbonCustomAction class
var ribbonCustomAction = new RibbonCustomAction();

// add one or more ribbon definitions, which will be deployed
// in same scope.
// RibbonCustomAction acts like a container for such definitions.
ribbonCustomAction.AddTab(myTab);

// Let's provision our custom action
// receiverGuid is a random constant Guid, which must be unique
// in the feature scope. It is used for cleanup in FeatureDeactivating
// method.
ribbonCustomAction.Provision(
    receiverGuid, 
    web, 
    ListTypes.GenericLibrary, 
    ListForms.All,
    SPBasePermissions.ManageLists);

// Next, we can provision the same custom action again and again to different
// locations. For example, let's register it for Links list:
ribbonCustomAction.Provision(
    receiverGuid, 
    web, 
    ListTypes.LinksList, 
    ListForms.All,
    SPBasePermissions.ManageLists);

Btw, Provision method has many overloads, in easiest case you should provide only 2-3 params.

You can find more samples at the project site.

P.S. Please, do not forget to add reference to RibbonUtils.dll & add record into GAC deployment list (Package.package, 'Advanced tab', Add -> Existing assembly)

share|improve this answer
    
Thanks for your solution, but I don't really know if our customer wants to deploy anything into GAC so maybe i'll try this approach later. –  Dmitriy Inozemtsev Apr 18 '11 at 14:07

This can be accomplished by duplicating the CustomAction xml section. Just copy the entire custom action section and paste below 1st CustomAction xml section and change RegistrationId to the next RegistrationId you want it to show up in.

share|improve this answer

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.