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.
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(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
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…
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.
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.
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).
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.
December 31, 2008 at 6:28 pm
brnwfevdzrwxfckawell, hi admin adn people nice forum indeed. how’s life? hope it’s introduce branch
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???
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
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
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
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.
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/