Removing menu items from SharePoint list

When removing menu items from a SharePoint action research will lead you to believe that you can create a new feature called HideCustomAction. However, this will only work for top level actions such as Site Actions.
So, what do you do when you need to remove a menu item from the list item.
On a SharePoint list the user can do things like Edit Items, Delete Items, Manage Permissions, Alert Me, etc. However, what if you don’t want something like the Edit Items link.

To do this you must modify javascript.
1. Locate the Core.js

2. Find the javascript method that creates the menu. You can do this by searching for the text, such as “Edit Item”. The first place you will find this text is in a variable such as “L_EditItem”. Then if you do a search on that variable you should find the method where the menu item is added. For example: Edit Item is added in AddSharedNamespaceMenuItems.

3. Lastly, modify the javascript to not show the menu item. For the Edit Item example:


function AddSharedNamespaceMenuItems(m, ctx)
{
   if(ctx.listTemplate != 105)
   {
       ….
   }
   AddManagePermsMenuItem(m, ctx, ctx.listName, currentItemID);
}

Now the Edit items wont show up for any list template number 105 (105 is the Contact List). If you want to do this for another type of list just find that list number in the feature of that list.

Note: I would not recommend changing the default Core.js to do this funcitonality. I would create a new custom javascript file and reference that from a custom master page file for the page. Thus, you can just use the custom master page for all pages that you want this functionality.

14 Responses to “Removing menu items from SharePoint list”

  1. kunz Says:

    Thank you for that hint. I was able to hide the Alert Me menu item in document libraries by updating

    if (HasRights(0×80, 0×0))
    to
    if (HasRights(0×80, 0×0) && (ctx.listTemplate != 920))

    This is done to times: in the AddDocLibMenuItems function and the AddListMenuItems function.

    where 920 is the list template id of my custom list :)

  2. Leon Zandman Says:

    This solution will only hide the menu items. If the user knows the correct URL he/she can still perform the action of the hidden menu item. Security through obscurity…

  3. Greg Galipeau Says:

    Yes, Leon. That is right. This post is not about security. You will have to inforce that yourself (probably through custom list definitions with custom forms that aren’t available). This post is about hiding menu items. It is a work around to a huge bug in the HideActions feature of SharePoint. It is meant to perform the same functionality of HideActions for regular site actions (which, by the way, aren’t security fixes either).
    So, I am just showing how to get to the same functionality that should have been there with HideActions.
    But, it is good to point out that neither my solution, or the out of the box SharePoint solution for hiding action menus, is a security implementation. It is exactly what it says – a “hide” implementation.

  4. Chayne Walsh Says:

    Another way to hide the Alert Me menu item is through custom permissions.
    Go to – Site Actions > Site Setting > Advanced Permissions > Settings > Permission Levels >

    From there you can either create a custom permissions level or simply remove the Create Alerts option in the permissions settings.

    E.g. Assuming you are already in Permission Levels click one of the permission levels such as “Read”. Under the heading “Permissions” uncheck “Create Alerts – Create e-mail alerts” and save.

    All users assigned Read permissions will no longer see the Alert Me menu item.

  5. Greg Galipeau Says:

    Thanks Chayne,
    Yes, that is another way. That way will take away all permissions levels, not just remove the menu item. So, you have to take that into consideration when choosing a way. When I originally wrote this blog I was dealing with a situation where I still wanted edit access to the item, I just didn’t want the menu on the ECB menu (i.e: I had another way into the edit form).

  6. Kevin Carbonaro Says:

    Hi,

    I think this could work for our situation, but I’m not an expert coder, and would appreciate some help with code I need to add;

    We have a Document Library where everyone files emails from outlook using an application called Colligo.

    Now, to enable users to modify item permissions, I have to give a custom Manage Permissions to all staff. All newly created items will inherit the Manage Permissions by default.

    However, users will also be able to choose the Manage Permissions of Parent from the Actions Menu.

    This is dangerous…and yes it happened… one user clicked it accidentally and the child permissions messed up, even those that do not inherit permissions. This happened because if from the parent you remove the ‘automatically generated’ permissions of users with Limited Access, then they are removed from the Child Items as well inherit or not.

    My question is how to remove this Manage Permissions of Parent.

    Thanks for any help given,

    Kevin C.

  7. drardbeishably Says:

    brnwfevdzrwxfckawell, hi admin adn people nice forum indeed. how’s life? hope it’s introduce branch ;)

  8. Sara Says:

    Is there a way to reference a specific row and field on the list so this only happens for specific conditions???

  9. sanket shah Says:

    Hey Greg,

    Very nice article and good information!!

    I have different situation from this and I am looking for solution, can you please help me for this?

    I would like to remove menu items “Edit Item” from specific custom list, if I go with above solution then it will remove “Edit Item” from all custom list, but what I need to do for removing option from only one list.

    OR

    Is there any way in which I can change URL of “Edit Item” page from EditItem.aspx to my layouts custom ASPX page? In SP designer, while changing page name (supporting files) from custom list, I can’t see files from layouts folder ..
    Actually finally I am looking for to give my custom ASPX page URL into “Edit Item” option or hide that option from specific list and add new custom action which will point to new layouts page, I already added new custom action into Edit Control block. But I am facing some of the challenges with other items.

    Thank you very much for your time.

    Thanks,
    Sanket Shah

  10. Vaishnavi Desai Says:

    HI Greg,

    I was very much fascinated by your blog.
    Could you please provide me with a way to disable or remove the “New” item option from the menu on Sharepoint list?
    Any help is appreciated.

    Thanks,
    Vaishnavi

  11. grinsepilz Says:

    Hi Greg,

    Thank you for the hint to the core.js.

    I couldn’t create a custom master page file, because of permissions. So I used some Javascript in a content-editor-webpart and overloaded the functions of the core.js with my custom core.js, which I placed somewhere in a documentlibrary.

    _spBodyOnLoadFunctionNames.push(“loadMyCore”);
    function loadMyCore(){
    var head = document.getElementsByTagName(‘head’)[0];
    var script = document.createElement(’script’);
    script.type = ‘text/javascript’;
    script.src = path/core1.js’;
    head.appendChild(script);
    }

    Works fine.

  12. prazjain Says:

    thanks, I did not know of this way to do the same thing.

    I did it programmatically and posted sometime back

    http://prazjain.wordpress.com/2009/07/15/using-spfolder-uniquecontenttypeorder-to-hide-menu-options/


Leave a Reply