none
SharePoint 2016 - can not add custom action to a folder in a custom list

    Question

  • Hi,

    in SharePoint 2013 I can easily add a custom action to the context menu of a custom list via the SharePoint Designer.

    In SharePoint 2013 the custom action shows up like this

    In SharePoint 2016 the custom action is not available

    Does someone know why it doesn't work and how I can add custom actions to a folder?
    By the way, it also doesn't work programmatically.

    Thanks in advanced!

    Tuesday, February 21, 2017 2:10 PM

Answers

  • Hi,

    Yes, it’s a known issue in SharePoint 2016.

    As a workaround, I suggest you add custom ECB using JavaScript:

    <script type="text/javascript">
    
    
    SP.SOD.executeFunc("callout.js", "Callout", function () {
    
    
      var itemCtx = {};
    
    
      itemCtx.Templates = {};
    
    
      itemCtx.BaseViewID = 'Callout';
    
    
      // Define the list template type
    
    
      itemCtx.ListTemplateType = 101;
    
    
      itemCtx.Templates.Footer = function (itemCtx) {
    
    
        // context, custom action function, show the ECB menu (boolean)
    
    
        return CalloutRenderFooterTemplate(itemCtx, AddCustomAction, true);
    
    
      };
    
    
      SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
    
    
    });
    
    
    function AddCustomAction (renderCtx, calloutActionMenu) {   
    
    
      // Add your custom action
    
    
      calloutActionMenu.addAction (new CalloutAction ({
    
    
        text: "Custom Action",
    
    
        tooltip: 'This is your custom action',
    
    
        onClickCallback: function() { console.log('Callback from custom action'); }
    
    
      }));
    
    
     
    
      // Show the default document library actions
    
    
      CalloutOnPostRenderTemplate(renderCtx, calloutActionMenu);
    
    
      // Show the follow action
    
    
      calloutActionMenu.addAction(new CalloutAction({
    
    
        text: Strings.STS.L_CalloutFollowAction,
    
    
        tooltip: Strings.STS.L_CalloutFollowAction_Tooltip,
    
    
        onClickCallback: function (calloutActionClickEvent, calloutAction) {
    
    
          var callout = GetCalloutFromRenderCtx(renderCtx);
    
    
          if (!(typeof(callout) === 'undefined' || callout === null))
    
    
            callout.close();
    
    
          SP.SOD.executeFunc('followingcommon.js', 'FollowSelectedDocument', function() { FollowSelectedDocument(renderCtx); });
    
    
        }
    
    
      }));
    
    
    }
    
    
    </script>
    

    I understand it will be more convenient if you can add custom action using SPD. It is suggested you post your feedback via Uservoice. This is the best way to let related team hear your voice. Many good features are added from users’ suggestions.

    Thanks for your understanding.

    Thanks,

    Dean Wang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, February 23, 2017 12:47 PM
    Moderator

All replies

  • Hi,

    Yes, it’s a known issue in SharePoint 2016.

    As a workaround, I suggest you add custom ECB using JavaScript:

    <script type="text/javascript">
    
    
    SP.SOD.executeFunc("callout.js", "Callout", function () {
    
    
      var itemCtx = {};
    
    
      itemCtx.Templates = {};
    
    
      itemCtx.BaseViewID = 'Callout';
    
    
      // Define the list template type
    
    
      itemCtx.ListTemplateType = 101;
    
    
      itemCtx.Templates.Footer = function (itemCtx) {
    
    
        // context, custom action function, show the ECB menu (boolean)
    
    
        return CalloutRenderFooterTemplate(itemCtx, AddCustomAction, true);
    
    
      };
    
    
      SPClientTemplates.TemplateManager.RegisterTemplateOverrides(itemCtx);
    
    
    });
    
    
    function AddCustomAction (renderCtx, calloutActionMenu) {   
    
    
      // Add your custom action
    
    
      calloutActionMenu.addAction (new CalloutAction ({
    
    
        text: "Custom Action",
    
    
        tooltip: 'This is your custom action',
    
    
        onClickCallback: function() { console.log('Callback from custom action'); }
    
    
      }));
    
    
     
    
      // Show the default document library actions
    
    
      CalloutOnPostRenderTemplate(renderCtx, calloutActionMenu);
    
    
      // Show the follow action
    
    
      calloutActionMenu.addAction(new CalloutAction({
    
    
        text: Strings.STS.L_CalloutFollowAction,
    
    
        tooltip: Strings.STS.L_CalloutFollowAction_Tooltip,
    
    
        onClickCallback: function (calloutActionClickEvent, calloutAction) {
    
    
          var callout = GetCalloutFromRenderCtx(renderCtx);
    
    
          if (!(typeof(callout) === 'undefined' || callout === null))
    
    
            callout.close();
    
    
          SP.SOD.executeFunc('followingcommon.js', 'FollowSelectedDocument', function() { FollowSelectedDocument(renderCtx); });
    
    
        }
    
    
      }));
    
    
    }
    
    
    </script>
    

    I understand it will be more convenient if you can add custom action using SPD. It is suggested you post your feedback via Uservoice. This is the best way to let related team hear your voice. Many good features are added from users’ suggestions.

    Thanks for your understanding.

    Thanks,

    Dean Wang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, February 23, 2017 12:47 PM
    Moderator
  • Hi Dean,

    Do you know if there is any more information on this know issue? Is it something the product group is working on a fix for so that it will work the same way as in SP2013 or is it supposed to work like this in SP2016?

    Tuesday, April 11, 2017 9:11 AM
  • Hello,

    Did you manage to apply any hot fix (or) raised with microsoft. we encountered similar issue, it would be great if you can share details if it was fixed any other way other than the javascript fix provided in this post.

    Thanks,

    Ashok

    Thursday, April 05, 2018 11:03 AM
  • This was fixed in May 2017 CU so if you're on a later build and still have problem with custom actions on folders it's probably some other issue.
    Thursday, April 05, 2018 3:08 PM