I was trying to add a custom action to my Custom list using Visual Studio 2013 and was pretty straight forward. But when I tried to do the same with Tasks list my custom ribbon action button never showed up. For custom tasks list it is little different compared to custom list template. Here is how you can add a Custom button for Tasks list:
1. Create Custom Tasks list using Tasks list template in SharePoint online. My list name here is "My Tasks"
2. Open VS 2013
3. Create a SharePoint hosted app and add a custom Ribbon action.
4 Below are the changes made in Elements.xml to make it to work
Replace CommandUIDefinition Location value with "Ribbon.Tasks.New.Controls._children"
and for Button Id value with "Ribbon.Tasks.New.RibbonCustomAction4Button"
In the example below I have custom ribbon action added to my "My Tasks" list.
This is how my Emelemts.xml looks like-
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="a3957d8c-dee7-4a6c-9d32-6e1531da84f5.GetReport"
RegistrationType="List"
RegistrationId="{$ListId:Lists/My Tasks;}"
Location="CommandUI.Ribbon"
Sequence="10001"
Title="Invoke 'GetReport' action" >
<CommandUIExtension>
<!--
Update the UI definitions below with the controls and the command actions
that you want to enable for the custom action.
-->
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Tasks.New.Controls._children">
<Button Id="Ribbon.Tasks.New.RibbonCustomAction4Button"
Alt="Request GetReport"
Sequence="100"
Command="Invoke_GetReportButtonRequest"
LabelText="GetReport"
TemplateAlias="o1"
Image32by32="_layouts/15/images/placeholder32x32.png"
Image16by16="_layouts/15/images/placeholder16x16.png" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="Invoke_GetReportButtonRequest"
CommandAction="~appWebUrl/Pages/Default.aspx?{StandardTokens}&SPListItemId={SelectedItemId}&SPListId={SelectedListId}"/>
</CommandUIHandlers>
</CommandUIExtension >
</CustomAction>
</Elements>
1. Create Custom Tasks list using Tasks list template in SharePoint online. My list name here is "My Tasks"
2. Open VS 2013
3. Create a SharePoint hosted app and add a custom Ribbon action.
4 Below are the changes made in Elements.xml to make it to work
Replace CommandUIDefinition Location value with "Ribbon.Tasks.New.Controls._children"
and for Button Id value with "Ribbon.Tasks.New.RibbonCustomAction4Button"
In the example below I have custom ribbon action added to my "My Tasks" list.
This is how my Emelemts.xml looks like-
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CustomAction Id="a3957d8c-dee7-4a6c-9d32-6e1531da84f5.GetReport"
RegistrationType="List"
RegistrationId="{$ListId:Lists/My Tasks;}"
Location="CommandUI.Ribbon"
Sequence="10001"
Title="Invoke 'GetReport' action" >
<CommandUIExtension>
<!--
Update the UI definitions below with the controls and the command actions
that you want to enable for the custom action.
-->
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Tasks.New.Controls._children">
<Button Id="Ribbon.Tasks.New.RibbonCustomAction4Button"
Alt="Request GetReport"
Sequence="100"
Command="Invoke_GetReportButtonRequest"
LabelText="GetReport"
TemplateAlias="o1"
Image32by32="_layouts/15/images/placeholder32x32.png"
Image16by16="_layouts/15/images/placeholder16x16.png" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="Invoke_GetReportButtonRequest"
CommandAction="~appWebUrl/Pages/Default.aspx?{StandardTokens}&SPListItemId={SelectedItemId}&SPListId={SelectedListId}"/>
</CommandUIHandlers>
</CommandUIExtension >
</CustomAction>
</Elements>
Deploy your app and see if the custom button "GetReport" shows up in the ribbon for "My Tasks" list.
No comments:
Post a Comment