Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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)

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top