2

Can You help to add custom button to Calendar. I have code for Document Library, but have no clue how to do same for Calendar. I see ribbon names in DevTools and tried to change groups and xml properties, but no luck.

Here is my code for Document Library view, how to do same for Calendar view?

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction Id="483fe75b-c3d1-4ec7-965d-30e8fc024517.MyRibbonButton"
                RegistrationType="List"
                RegistrationId="{$ListId:Custom_Docs;}"
                Location="CommandUI.Ribbon"
                Sequence="10001"
                Title="My Ribbon Button action">
    <CommandUIExtension xmlns="http://schemas.microsoft.com/sharepoint/">
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.Documents.Groups._children">
          <Group Id="My Ribbon Button" Title="My Ribbon Button" Template="Ribbon.Templates.Flexible2" Command="My Ribbon Button.Command">
            <Controls Id="My Ribbon Button.Controls">
              <Button Id="Ribbon.Documents.Share.PublishToHomeButton"
                  Alt="My Button"
                  Sequence="100"
                  Command="Invoke_MyButtonEvent"
                  LabelText="My Button"
                  TemplateAlias="o1"
                  Image32by32="/_layouts/15/images/stsappcatalogribbon16x16.png?rev=23"
                  Image16by16="/_layouts/15/images/stsappcatalogribbon32x32.png?rev=23" />
            </Controls>
          </Group>
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.Documents.Scaling._children">
          <MaxSize Id="My Ribbon Button.Scaling.MaxSize" GroupId="My Ribbon Button" Size="LargeLarge" />
        </CommandUIDefinition>
        <CommandUIDefinition Location="Ribbon.Templates._children">
          <GroupTemplate Id="Ribbon.Templates.Flexible2">
            <Layout Title="LargeLarge" LayoutTitle="LargeLarge">
              <OverflowSection DisplayMode="Large" TemplateAlias="o1" Type="OneRow" />
              <OverflowSection DisplayMode="Large" TemplateAlias="o2" Type="OneRow" />
            </Layout>
            <Layout Title="LargeMedium" LayoutTitle="LargeMedium">
              <OverflowSection DisplayMode="Large" TemplateAlias="o1" Type="OneRow" />
              <OverflowSection DisplayMode="Medium" TemplateAlias="o2" Type="ThreeRow" />
            </Layout>
            <Layout Title="LargeSmall" LayoutTitle="LargeSmall">
              <OverflowSection DisplayMode="Large" TemplateAlias="o1" Type="OneRow" />
              <OverflowSection DisplayMode="Small" TemplateAlias="o2" Type="ThreeRow" />
            </Layout>
            <Layout Title="MediumLarge" LayoutTitle="MediumLarge">
              <OverflowSection DisplayMode="Medium" TemplateAlias="o1" Type="ThreeRow" />
              <OverflowSection DisplayMode="Large" TemplateAlias="o2" Type="OneRow" />
            </Layout>
            <Layout Title="MediumMedium" LayoutTitle="MediumMedium">
              <OverflowSection DisplayMode="Medium" TemplateAlias="o1" Type="ThreeRow" />
              <OverflowSection DisplayMode="Medium" TemplateAlias="o2" Type="ThreeRow" />
            </Layout>
            <Layout Title="MediumSmall" LayoutTitle="MediumSmall">
              <OverflowSection DisplayMode="Medium" TemplateAlias="o1" Type="ThreeRow" />
              <OverflowSection DisplayMode="Small" TemplateAlias="o2" Type="ThreeRow" />
            </Layout>
            <Layout Title="SmallLarge" LayoutTitle="SmallLarge">
              <OverflowSection DisplayMode="Small" TemplateAlias="o1" Type="ThreeRow" />
              <OverflowSection DisplayMode="Large" TemplateAlias="o2" Type="OneRow" />
            </Layout>
            <Layout Title="SmallMedium" LayoutTitle="SmallMedium">
              <OverflowSection DisplayMode="Small" TemplateAlias="o1" Type="ThreeRow" />
              <OverflowSection DisplayMode="Medium" TemplateAlias="o2" Type="ThreeRow" />
            </Layout>
            <Layout Title="SmallSmall" LayoutTitle="SmallSmall">
              <OverflowSection DisplayMode="Small" TemplateAlias="o1" Type="ThreeRow" />
              <OverflowSection DisplayMode="Small" TemplateAlias="o2" Type="ThreeRow" />
            </Layout>
          </GroupTemplate>
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="My Ribbon Button.Command" CommandAction="javascript:alert('Hi!');" />
        <CommandUIHandler Command="Invoke_MyButtonEvent"
                  CommandAction="javascript:alert('Hi!');"
                  EnabledScript="javascript:SP.ListOperation.Selection.getSelectedItems().length == 1;"/>
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>

It is attached to 'Custom_Docs' list:

enter image description here

I want to add my custom group to existing 'Events' tab in Calendar, but simple change does not help, I get error during activation

enter image description here

Maybe somewone have existing example for Calendar tabs?

-- Update: Thank You for answer!

I tried to change but get activation errors. I also have no Add > New Item > Office/SharePoint > "Ribbon Custom Action" in my VS menu..

<CommandUIDefinition Location="Ribbon.Calendar.Events.Groups._children">  <!--here-->
  <Group Id="My Ribbon Button" Title="My Ribbon Button" Template="Ribbon.Templates.Flexible2" Command="My Ribbon Button.Command">
    <Controls Id="My Ribbon Button.Controls">
      <Button Id="Ribbon.Documents.Share.PublishToHomeButton"
          Alt="My Button"
          Sequence="100"
          Command="Invoke_MyButtonEvent"
          LabelText="My Button"
          TemplateAlias="o1"
          Image32by32="/_layouts/15/images/stsappcatalogribbon32x32.png?rev=23"
          Image16by16="/_layouts/15/images/stsappcatalogribbon16x16.png?rev=23" />
    </Controls>
  </Group>
</CommandUIDefinition>
<CommandUIDefinition Location="Ribbon.Calendar.Events.Actions.Controls._children">  <!--here-->
  <MaxSize Id="My Ribbon Button.Scaling.MaxSize" GroupId="My Ribbon Button" Size="LargeLarge" />
</CommandUIDefinition>

-- Update 2: Ok, I found that "Adde Ribbon Custom Action" is available for 'SharePoint-Hosted App' projects. But it does not help much..

1
  • Images are wrong in this code-snippet, etc. It is just for example. I also tried to install DevTools on my VS2017, looking for "Ribbon Custom Action" template, but no luck. I tried VS Developer Tools and CKSDev for Visual Studio 2015, and 2013 too..
    – Gennady G
    Commented Dec 12, 2018 at 12:08

1 Answer 1

1

My XML Custom Action Calendar, maybe helped, you need Ribbon.Calendar.Events.Actions.Controls._children, sometimes changes take effect only after IIS reset:

    <CustomAction
   Id="EmailButton"
   Location="CommandUI.Ribbon"
   RegistrationId="100"
   RegistrationType="List"
   Sequence="5"
   Title="Email">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
         Location="Ribbon.ListItem.Share.Controls._children">
          <Button
           Id="Ribbon.ListItem.Share.Controls.Email"
           Alt="Email"
           Command="Email"
           Image16by16="/_layouts/images/Email.gif"
           Image32by32="/_layouts/images/centraladmin_systemsettings_email_32x32.png"
           LabelText="E-mail"
           TemplateAlias="o1"
           Sequence="30" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler 
          Command="Email" 
          CommandAction="javascript:..."
          />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
1
  • >> sometimes changes take effect only after IIS reset - I hit Ctrl+F5 to refresh cache, it refreshes custom actions.. Updated post.
    – Gennady G
    Commented Dec 12, 2018 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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