Home > sharepoint > Removing menu items from SharePoint list

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.

Advertisements
Categories: sharepoint
  1. kunz
    May 22, 2008 at 3:01 pm

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

    if (HasRights(0x80, 0x0))
    to
    if (HasRights(0x80, 0x0) && (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. July 16, 2008 at 8:16 am

    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
    July 16, 2008 at 12:40 pm

    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
    October 8, 2008 at 4:02 am

    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
    October 8, 2008 at 12:01 pm

    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
    November 26, 2008 at 7:47 am

    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
    December 31, 2008 at 6:28 pm

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

  8. March 3, 2009 at 10:26 pm

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

  9. July 18, 2009 at 8:37 pm

    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

    • Greg Galipeau
      July 18, 2009 at 9:03 pm

      The only way I know to do that is with code. Here is an article on the subject: http://blog.qumsieh.ca/2009/05/15/how-to-change-the-default-editform-newform-and-dispform/ The basis of the article is that you need to create a custom content type to associate to your list. Then, in code you can change the redirect paths for the edit, display and new forms. Hope this is what you are looking for

      • July 18, 2009 at 9:48 pm

        Thanks Greg, yeah I am looking for similar type of solutions or alternatives, code seems very promising for me.

        I appreciated your help.

        -Sanket

  10. Vaishnavi Desai
    July 20, 2009 at 8:50 pm

    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
    August 26, 2009 at 1:01 pm

    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
    November 13, 2009 at 1:10 pm

    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/

  13. February 8, 2010 at 11:47 am

    Good one.Even i want to add to this.
    A common requirement that every Sharepoint developer is asked for today is customization of the SharePoint site based on various customer specific requirements. Most often customers have requirements where they want to add some additional features to action menus like Site action menu, ECB menu or List/library Action menu, etc. To achieve this, we have to write custom action in XML and consume it within the site as a new feature. In Sharepoint if we need to integrate new feature for a List / Library, we can achieve this easily by creating a custom action feature.

  14. February 25, 2010 at 8:44 am

    It took a bit for the post to load but i’m happy i waited.

  15. January 7, 2016 at 3:59 pm

    Manche Zeitgenossen veröffentlichen sehr viele oder gar störende
    Neuigkeiten bei XING.

  16. February 13, 2016 at 2:49 am

    So ist es beispielsweise normal, bei Aufregung einen höheren Blutdruck zu haben, ganz ohne
    dass krankhafter Bluthochdruck vorliegt.

  17. March 15, 2016 at 9:22 pm

    Um eine spätere Reparatur zu ermöglichen, muss das betroffene Areal trocken und sauber bleiben.

  18. March 19, 2016 at 5:22 pm

    Die Herstellung ist denkbar einfach und gewährleistet durch eine schonende Garung, dass auch wichtige Inhaltstoffe enthalten bleiben.

  19. April 3, 2016 at 2:39 am

    Eine Ernährungsweise, mit der man – wenn man krank ist – gesund wird und – wenn man gesund ist
    – dauerhaft gesund bleibt.

  20. April 5, 2016 at 11:03 pm

    Ergänzen kann man die Behandlung mit dem Salz Nr.
    5. Kalium phosphoricum, welches gute Wirkung bei Erschöpfung
    und Herzschwäche zeigt.

  21. April 9, 2016 at 8:00 pm

    Natürlich geht es beim Kampfsport in der heutigen Zeit nicht mehr darum den Gegner bewusst zu schädigen.

  22. April 10, 2016 at 9:28 am

    Zu den diätetischen Lebensmitteln zählt auch der Kochsalzersatz und Lebensmittel,
    die mit Kochsalzersatz hergestellt wurden.

  23. April 20, 2016 at 9:41 am

    Einfach bewusst hat 100.000 Seitenaufrufe pro Monat, 9.000 Social-Media-Follower und 6.000 Newsletter
    – & Feed -Abonnenten.

  24. June 29, 2016 at 4:38 pm

    Auch mit einem wenige Wochen alten Säugling können Sie problemlos
    verreisen, wenn Sie und Ihr Kind sich fit fühlen.

  25. July 3, 2016 at 7:51 am

    Gut, sauber und fair müssen Slow-Food-Produkte laut
    Definition von Gründer Carlo Petrini sein.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: