Domanda

In one of my POC, there is a requirement to create custom action Ribbon menu for Task List. After lot of research I have tried below code snippet in empty module to add custom action.

<CustomAction Id="ActionButton" RegistrationId="107" RegistrationType="List" Location="CommandUI.Ribbon" Title="Add a Action button for tasks list">
 <CommandUIExtension>
  <CommandUIDefinitions>
    <CommandUIDefinition Location="Ribbon.Tasks.Actions.Controls._children">
      <Button Id="Ribbon.Tasks.Actions.ActionButton"
              Alt="Perform an action for task items."
              Sequence="10"
              Command="ActionButtonCommand"
              LabelText="Action Button"
              TemplateAlias="o1"
              Image32by32="/_layouts/15/ActionRibbon/img/action-32x32.png"
              Image16by16="/_layouts/15/ActionRibbon/img/delete-all-16x16.png" />
    </CommandUIDefinition>
  </CommandUIDefinitions>
  <CommandUIHandlers>
    <CommandUIHandler Command="ActionButtonCommand" CommandAction="javascript:alert('Whoa..! You performed an action!');">
    </CommandUIHandler>
  </CommandUIHandlers>
</CommandUIExtension>

I have made sure that RegistrationId for Tasks list is 107. Also checked this Location for CommandUIDefinitation.

When I try to add the same custom action to the any of the task list from SharePoint designer and specify the location Ribbon.Tasks.Actions.Controls._children. Custom Action does appear but, when I do the same with Visual studio as farm solution, custom action does not appear at all.

Can some one help me? It would be great help. Thanks in advance.

È stato utile?

Soluzione

Well, After digging lot into web I found out that the RegistrationID for Tasks List is 171 from this link, so below code block has worked for me:

<CustomAction Id="ActionButton" RegistrationId="171" RegistrationType="List" Location="CommandUI.Ribbon" Title="Add a Action button for tasks list">
 <CommandUIExtension>
  <CommandUIDefinitions>
    <CommandUIDefinition Location="Ribbon.Tasks.Actions.Controls._children">
      <Button Id="Ribbon.Tasks.Actions.ActionButton"
              Alt="Perform an action for task items."
              Sequence="10"
              Command="ActionButtonCommand"
              LabelText="Action Button"
              TemplateAlias="o1"
              Image32by32="/_layouts/15/ActionRibbon/img/action-32x32.png"
              Image16by16="/_layouts/15/ActionRibbon/img/delete-all-16x16.png" />
    </CommandUIDefinition>
  </CommandUIDefinitions>
  <CommandUIHandlers>
    <CommandUIHandler Command="ActionButtonCommand" CommandAction="javascript:alert('Whoa..! You performed an action!');">
    </CommandUIHandler>
  </CommandUIHandlers>
 </CommandUIExtension>
</CustomAction>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top