Answered Problem while adding custom menu item in document library

  • Tuesday, July 07, 2009 10:46 AM
     
      Has Code
    Hi,

    I have written a feature(Site scoped) that adds custom menu items to the New Menu and EditControlBlock of document library. These menu items should show up only when the user has add and edit permissions for that document library. This works great except for one particular case where the user has only read permission for the parent site but has full control over the document library. In this case the menu items under EditControlBlock show up correctly but the menu items under New menu do not show up. I have set the same rights for all the menu items. Below are the sample entries in Feature and Element manifest file

    <?xml version="1.0" encoding="utf-8" ?>
    <Feature
      Id="59bba8e7-0cfc-46e3-9285-4597f8085e76"
      Title="My Custom Menus"
      Scope="Site"
      xmlns="http://schemas.microsoft.com/sharepoint/">
      <ElementManifests>
        <ElementManifest Location="Elements.xml" />
      </ElementManifests>
    </Feature>

    <?xml version="1.0" encoding="utf-8" ?>
    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    
    <CustomAction Id="EditMenu1" RegistrationType="FileType" RegistrationId="txt" Location="EditControlBlock" Sequence="106" ImageUrl="/_layouts/images/PPT16.GIF" Title="My Edit Menu" Rights="AddListItems,EditListItems">
        <UrlAction Url="javascript:var surl='{SiteUrl}'; window.location='/test/mypage.aspx?siteurl='+surl+'&amp;itemurl={ItemUrl}&amp;itemid={ItemId}&amp;listid={ListId}&amp;Source='+window.location" />
      </CustomAction>
    
    <CustomAction Id="NewMenu1" GroupId="NewMenu" RegistrationType="List" RegistrationId="101" Location="Microsoft.SharePoint.StandardMenu" Sequence="1002" ImageUrl ="/_layouts/images/DOC32.GIF" Title="My New Menu" Rights="AddListItems,EditListItems">
        <UrlAction Url="javascript:var surl='{SiteUrl}'; window.location='/test/mypage.aspx?siteurl='+surl+'&amp;listid={ListId}&amp;Source='+window.location" />
      </CustomAction>
    </Elements>
     Am I missing anything? Please advice.

    Regards,
    Jagannath

Answers

  • Monday, July 13, 2009 3:11 AM
    Moderator
     
     Answered

    Hi Jagannath,

     

    I’m able to reproduce this symptom.

    It seems that the “Rights” of “EditControlBlock” belongs to the list(library), thus a user who has full permission can get this entry properly.

     

      <CustomAction Id="EditMenu1"

                    RegistrationType="FileType"

                    RegistrationId="txt"

                    Location="EditControlBlock"

                    Sequence="106"

                    Title="My Edit Menu"

                    Rights="AddListItems,EditListItems">

        <UrlAction Url="#" />

      </CustomAction>

     

    It also seems that the “Rights” of “Microsoft.SharePoint.StandardMenu” belongs to the parent site, therefore a user who has only read permission cannot get the entry properly. (If you change the “Rights” in “NewMenu1” to “ViewListItems”, this entry will show up.)

     

      <CustomAction Id="NewMenu1"

                    GroupId="NewMenu"

                    RegistrationType="List"

                    RegistrationId="101"

                    Location="Microsoft.SharePoint.StandardMenu"

                    Sequence="1002"

                    ImageUrl ="/_layouts/images/DOC32.GIF"

                    Title="My New Menu"

                    Rights="AddListItems,EditListItems">

        <UrlAction Url="#" />

      </CustomAction>

     

    You might consider some workarounds:

    1.       Change the “Location” of the “NewMenu1” to the list(library) level.

    2.       Change the permission for those users.

All Replies

  • Monday, July 13, 2009 3:11 AM
    Moderator
     
     Answered

    Hi Jagannath,

     

    I’m able to reproduce this symptom.

    It seems that the “Rights” of “EditControlBlock” belongs to the list(library), thus a user who has full permission can get this entry properly.

     

      <CustomAction Id="EditMenu1"

                    RegistrationType="FileType"

                    RegistrationId="txt"

                    Location="EditControlBlock"

                    Sequence="106"

                    Title="My Edit Menu"

                    Rights="AddListItems,EditListItems">

        <UrlAction Url="#" />

      </CustomAction>

     

    It also seems that the “Rights” of “Microsoft.SharePoint.StandardMenu” belongs to the parent site, therefore a user who has only read permission cannot get the entry properly. (If you change the “Rights” in “NewMenu1” to “ViewListItems”, this entry will show up.)

     

      <CustomAction Id="NewMenu1"

                    GroupId="NewMenu"

                    RegistrationType="List"

                    RegistrationId="101"

                    Location="Microsoft.SharePoint.StandardMenu"

                    Sequence="1002"

                    ImageUrl ="/_layouts/images/DOC32.GIF"

                    Title="My New Menu"

                    Rights="AddListItems,EditListItems">

        <UrlAction Url="#" />

      </CustomAction>

     

    You might consider some workarounds:

    1.       Change the “Location” of the “NewMenu1” to the list(library) level.

    2.       Change the permission for those users.

  • Tuesday, July 14, 2009 11:41 AM
     
     
    Hi Charlie,

    Appreciate your help in reproducing the problem and suggesting workarounds. Couple of thoughts on your workarounds

    1. As my menus are specific to creating New items it would not be appropriate for me to move them to some other location. Also I could not find a suitable location on the list toolbar that has document library permissions.
    2. As my stuff will be used by external customers it would not be appropriate to ask them to change the permission for the users.

    Changing the rights in NewMenu to 'ViewListItems' may bring up the menu items but there could be a possibility that a user has view permissions at the site level but does not have any permissions for a document library under it. In this case showing the NewMenu item will not be appropriate.

    Regards,
    Jagannath