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

By following the examples in the SP 2010 C# Hands On Lab (SPCHOL308), I've gotten a CustomAction button to show up under the View tab in the Manage group on the DisplayForm.

I want to place this button in a new group called 'Reservations', but I am unable to see my CustomActionGroup.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomActionGroup
     Id="Reservations"
     Location="CommandUI.Ribbon.DisplayForm"
     Sequence="1000"
     Title="Reservations">
  </CustomActionGroup>
  <CustomAction 
    Id="Ribbon.ListForm.Display.Reservations.ReturnCustomAction" 
    RegistrationId="106" 
    RegistrationType="List" 
    Location="CommandUI.Ribbon.DisplayForm" 
    Title="Mark as Returned"
    GroupId="Reservations">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition 
           Location="Ribbon.ListForm.Display.Manage.Controls._children">
                <Button
                  Id="Ribbon.ListForm.Display.Reservations.Return"
                  Alt="Mark as Returned"
                  Sequence="10"
                  Command="MarkAsReturned"
                  Image32by32="/_layouts/images/EquipmentReservations/Home2.png"
                  LabelText="Mark as Returned"
                  TemplateAlias="o1"
              />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler 
          EnabledScript="return true;"
          Command="MarkAsReturned" 
          CommandAction="javascript:alert('hello there');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>

Can someone point me to a working example or paste one here for me? I've googled but all I seem to find is adding a group to an administration or site page.

I've also tried what Bil Simser posted here Buttons not appearing in custom ribbon group applying the responses, but when I do that, I get xml schema validation errors (doesn't like adding the Scaling element above the Group element.

All I really want to do is add some buttons to the display form so they can launch a workflow automatically without displaying the initiation form. But I want these in a group.

I'm a developer, but relatively new the sharepoint scene. Any help would be greatly appreciated.

By the way, I'm using the Group Calendar list from a Group Worksite based site.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

You have misunderstanding of using CustomActionGroup. It uses for creating groups not in ribbon, but in sharepoint pages, for example in site settings. Chris O'Brien has written good blog posts about ribbon customization here. And if you have doubts how to create ribbon button or group, it is good idea to digg into cmdui.xml (this file contains definition for all ribbon elements is sharepoint, under 14\TEMPLATE\GLOBAL\XML\).

If you want to create group in ribbon with button or other controls, you should provide three required CommandUIDefinition- GroupTemplate, Scaling and Group with controls. You can reuse one of oob sharepoint groups, but as @Andy Burns mentioned in one of the answers to question you provided (and from my experience), its better to always creates own group template.
So, your button definition should look like this one:

<CustomAction
    Id="Ribbon.ListForm.Display.Reservations.ReturnCustomAction"
    RegistrationId="106"
    RegistrationType="List"
    Location="CommandUI.Ribbon.DisplayForm"
    Title="Mark as Returned"
    GroupId="Reservations">
    <CommandUIExtension>
      <CommandUIDefinitions>

        <CommandUIDefinition Location="Ribbon.Templates._children">
          <GroupTemplate Id="Reservations.Templates">
            <Layout Title="Large">
              <Section Type="OneRow">
                <Row>
                  <ControlRef TemplateAlias="c1" DisplayMode="Large" />
                </Row>
              </Section>
            </Layout>
          </GroupTemplate>
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.ListForm.Display.Scaling._children">
          <MaxSize Id="Ribbon.ListForm.Display.CustomActionGroup.MaxSize"
                   Sequence="55"
                   GroupId="Ribbon.ListForm.Display.CustomActionGroup"
                   Size="Large" />
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.ListForm.Display.Groups._children">
          <Group Id="Ribbon.ListForm.Display.CustomActionGroup"
                 Sequence="155"
                 Description="Group for reservations"
                 Title="Reservations"
                 Template="Reservations.Templates">
            <Controls Id="Ribbon.ListForm.Display.CustomActionGroup.Controls">
              <Button Id="Ribbon.ListForm.Display.CustomActionGroup.Reservations.Return"
                      Command="MarkAsReturned"
                      Sequence="55"
                      Image16by16="/_layouts/1033/images/formatmap16x16.png"
                      Image32by32="/_layouts/1033/images/formatmap32x32.png" Image32by32Left="-352"
                      Description="Add selected applications to a group"
                      LabelText="Mark as Returned"
                      TemplateAlias="c1" />
            </Controls>
          </Group>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
          EnabledScript="return true;"
          Command="MarkAsReturned"
          CommandAction="javascript:alert('hello there');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>

You can play with different group template attributes to see the effect.

share|improve this answer
    
Thank you for the clarification. Your answer was clear and concise and worked perfectly. I spent two days on this. With your help I got it working in a couple of minutes. Thanks again. –  marvin Apr 5 '12 at 16:29

CustomActionGroup are used to be able to put CustomAction links into new groups on Site setting and Central Administraion.

But it has nothing to do with the Ribbon groups. In the ribbon you should use Group elements like Bill Simser is doing in the post you linked to yourselves, just remember to add the Scaling and GroupTemplate.

Maybe take a look at the MSDN article Server Ribbon XML

It can be a bit confusing because they decided to reuse the CustomAction which was just link in SP2007 to implement ribbon controls, but not use CustomActionGroups for that.

share|improve this answer
    
I had looked at that article, but was confused about the Scaling element and it's placement. @Kai's response clarified that for me. Thanks for your help too. –  marvin Apr 5 '12 at 16:34

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.