What's on the Menu? - How to Remove Items from a Document Library Drop-down Menu
The SDK includes documentation explaining how to create a custom Jscript file that can override the default functions that create items in the cute little drop-down menu associated with list items. For example, the drop-down below is for a PowerPoint presentation in a WSS document library:
The SDK describes how to override a default method (AddCheckinCheckoutMenuItem) in order to create a new Check Out & Save item on the menu.
Customizing the Shortcut Menu for List Items
However, what if we want to *remove* items from the menu? For example, let's say that we want to remove the "Edit in Microsoft Office…" link from the menu so that our users are not presented with that option; how would we go about it? How would we override default methods in order to remove any of the other items on the menu (Alert Me, Discuss, etc.)?
To begin, we have to look at the function in ows.js that creates the document library menu items: AddDocLibMenuItems. Within this function, you'll see a bunch of calls to the CAMOpt function, which is also defined in ows.js. CAMOpt is the function responsible for actually writing each menu item; if we remove the call to CAMOpt for a specific menu item, we effectively remove that menu item!
For example, the AddDoclibMenuItems function contains the following code, which writes the "Edit in [Application]" menu item:
setDocType();
if (currentItemAppName != "" && currentItemOpenControl != "")
{
strDisplayText = StBuildParam(L_EditIn_Text, currentItemAppName);
strAction = "editDocumentWithProgID2('" + currentItemFileUrl + "', '" + currentItemProgId + "', '" + currentItemOpenControl + "')";
strImagePath = ctx.imagesPath + currentItemIcon;
CAMOpt(m, strDisplayText, strAction, strImagePath);
}
If we comment out the call to CAMOpt…
//CAMOpt(m, strDisplayText, strAction, strImagePath);
...the "Edit in [Application]" item/option will no longer show up for menus on document library items. Below is a screenshot of the menu for a PowerPoint presentation on a WSS site where a custom ows.js file has been applied (following the instructions in Customizing the Shortcut Menu for List Items) that *only* includes an overridden AddDoclibMenuItems function with the specific CAMOpt call above commented out:
So, how can you figure out which CAMOpt call is adding which menu item? Simple. :) The second parameter passed is the display text (strDisplayText); all of the calls to CAMOpt in AddDocLibMenuItems use a string constant for this parameter. The string constants are defined in ows.js, and I've reprinted them below:
=====
var L_Edit_Text= "Edit";
var L_ViewItem_Text= "View Item";
var L_EditItem_Text= "Edit Item";
var L_EditSeriesItem_Text = "Edit Series";
var L_DeleteItem_Text= "Delete Item";
var L_DeleteDocItem_Text = "Delete";
var L_ViewProperties_Text = "View Properties";
var L_EditProperties_Text = "Edit Properties";
var L_Discuss_Text= "Discuss";
var L_Subscribe_Text= "Alert Me";
var L_Review_Text= "Send for Review";
var L_EditIn_Text= "Edit in ^1";
var L_Checkin_Text= "Check In";
var L_Checkout_Text= "Check Out";
var L_CreateDWS_Text= "Create Document Workspace";
var L_PublishBack_Text= "Publish to Source Location";
var L_Versions_Text= "Version History";
var L_Reply_Text= "Reply";
var L_ExportContact_Text = "Export Contact";
var L_ExportEvent_Text= "Export Event";
var L_Reschedule_Text= "Rescheduling Options";
var L_Move_Text= "Move";
var L_Keep_Text= "Keep";
var L_Delete_Text= "Delete";
var L_Open_Text= "Open";
var L_SiteSettings_Text = "Change Site Settings";
var L_ManageUsers_Text= "Manage Users";
var L_DeleteSite_Text= "Delete Site";
var L_SiteStorage_Text= "Manage Site Storage";
var L_Sharing_Text= "Sharing";
var L_Settings_Text= "Settings";
var L_Remove_Text= "Remove from this list";
var L_ModerateItem_Text = "Approve/reject";
var L_DownloadOriginal_Text = "Download Picture";
var L_EditVersion_Text= "Edit";
var L_ViewVersion_Text= "View";
var L_RestoreVersion_Text = "Restore";
var L_DeleteVersion_Text = "Delete";
var L_EditInOIS_Text= "Edit Picture";
var L_AddToMyLinks_Text = "Add to My Links";
var L_AddToCategory_Text = "Submit to Portal Area";
=====
So, you can simply find the display text of the item you want to remove [from ALL sites], find its string constant (e.g. L_Subscribe_Text for "Alert Me"), find the corresponding CAMOpt call by searching for the string constant name in your AddDocLibMenuItems function -- in your custom .js file -- and comment it out.
Ta-da.
NOTE of course, that making changes directly to ows.js is not supported, and can potentially cause other unexpected problems. Additionally, a custom .js file should only be applied to a custom site definition as described in the article above. If you follow the rules, though, you can make a wide variety of customizations to the way that items are displayed in SharePoint sites!
Comments
Anonymous
June 18, 2006
Ryan,
If I am not mistaking, ows.js (or a custom js) is system wide. What if I wanted to remove a menu item for a specific library?
Regards
Gilles Sylvestre
gilles.sylvestre@techtra.caAnonymous
August 22, 2006
I have followed your advice and comment out the call to "delete item" options in drop down menus. It works fine.
I now would like to enable the "Delete Item" option just for Administrator. I do not want it to be visible for any other user.
How do I put “IF” statement to limit it?
Thanks.
RonAnonymous
August 28, 2006
(I am resubmitting the same message with the hope of any response. Thanks.)
I have followed your advice and comment out the call to "delete item" options in drop down menus. It works fine.
I now would like to enable the "Delete Item" option just for Administrator. I do not want it to be visible for any other user.
How do I put “IF” statement to limit it?
Thanks.
RonAnonymous
October 23, 2006
Thank you so much for this great post about <a href="http://cheapmedical.50megs.com/claim-compensation.html"">http://cheapmedical.50megs.com/claim-compensation.html" title="claim compensation">claim compensation</a> and [URL=http://cheapmedical.50megs.com/claim-compensation.html]claim compensation[/URL]Anonymous
October 23, 2006
Thank you so much for this great post about <a href="http://cheapmedical.50megs.com/claim-compensation.html"">http://cheapmedical.50megs.com/claim-compensation.html" title="claim compensation">claim compensation</a> and [URL=http://cheapmedical.50megs.com/claim-compensation.html]claim compensation[/URL]Anonymous
October 23, 2006
Thank you so much for this great post about <a href="http://cheapmedical.50megs.com/claim-compensation.html"">http://cheapmedical.50megs.com/claim-compensation.html" title="claim compensation">claim compensation</a> and [URL=http://cheapmedical.50megs.com/claim-compensation.html]claim compensation[/URL]Anonymous
October 23, 2006
Thank you so much for this great post about <a href="http://eteamz.active.com/creditonline/files/card-credit-ecommerce-processing.html"">http://eteamz.active.com/creditonline/files/card-credit-ecommerce-processing.html" title="card credit ecommerce processing">card credit ecommerce processing</a> and [URL=http://eteamz.active.com/creditonline/files/card-credit-ecommerce-processing.html]card credit ecommerce processing[/URL]Anonymous
October 27, 2006
The comment has been removedAnonymous
October 27, 2006
Excellent browsing have the toAnonymous
October 28, 2006
Thanks for the great tips about <a href="http://johnostin.50megs.com/black-game-jack.html"">http://johnostin.50megs.com/black-game-jack.html" title="black game jack">black game jack</a> and [URL=http://johnostin.50megs.com/black-game-jack.html]black game jack[/URL]Anonymous
October 28, 2006
The comment has been removedAnonymous
October 28, 2006
Thanks for the great tips about <a href="http://calistanorris.bravehost.com/campsite-nice.html"">http://calistanorris.bravehost.com/campsite-nice.html" title="campsite nice">campsite nice</a> and [URL=http://calistanorris.bravehost.com/campsite-nice.html]campsite nice[/URL]Anonymous
November 23, 2006
The comment has been removedAnonymous
November 24, 2006
I love you! <a href=http://akoc-icco.ru/wholesale-toy>wholesale toy</a>Anonymous
November 25, 2006
<a href=http://akoc-icco.ru/wholesale-tire>wholesale tire</a>Anonymous
November 26, 2006
<a href=http://akoc-icco.ru/wholesale-silk-flower>wholesale silk flower</a>Anonymous
November 26, 2006
<a href=http://akoc-icco.ru/wholesale-ribbon>wholesale ribbon</a>Anonymous
November 28, 2006
<a href= http://forum.lixium.fr/cgi-bin/liste.eur?wellbut > wellbutrin sr </a> [url= http://forum.lixium.fr/cgi-bin/liste.eur?wellbut ] wellbutrin medication [/url]Anonymous
December 01, 2006
Excellent browsing have the toAnonymous
December 07, 2006
Excellent browsing have the toAnonymous
December 07, 2006
Excellent browsing have the toAnonymous
December 08, 2006
Very good project! <a href= www.debtconsolidation.newov.info >debt consolidation</a> <a href= www.badcreditloan.newov.info >bad credit loan</a>Anonymous
December 10, 2006
Excellent browsing have the toAnonymous
December 11, 2006
Well, your site is very good, good news and design...! ))) Happy Christmas! SmilerMan.Anonymous
December 14, 2006
Very nice resources!<a href= http://betting.ggfix.com >betting</a> <a href= http://wagering.ggfix.com >wagering</a>Anonymous
December 18, 2006
Excellent browsing have the toAnonymous
December 23, 2006
Beautiful site!,Beautiful site!Anonymous
January 18, 2007
Great site. I will bookmark for my sons to view as well!!! <a href= http://docs.google.com/View?docid=df2wwh2p_7c7mc89 >Debt Consolidation</a> [url=http://docs.google.com/View?docid=df2wwh2p_7c7mc89]Debt Consolidation[/url] good luckAnonymous
January 19, 2007
Awesome site! Design is great! Please visit my homepage too: <a href= http://fm7.biz/0l6s >buy valium</a> [url=http://fm7.biz/0l6s]buy valium[/url]Anonymous
January 21, 2007
Excellent browsing have the toAnonymous
January 22, 2007
Excellent browsing have the toAnonymous
January 24, 2007
Thank you! http://symy.jp/?Ct_220745,Thank">http://symy.jp/?Ct_220745,Thank you! http://symy.jp/?Ct_220745Anonymous
January 24, 2007
Excellent browsing have the toAnonymous
January 29, 2007
Nice site! http://32url.com/?iSlf,Nice">http://32url.com/?iSlf,Nice site! http://32url.com/?iSlfAnonymous
February 04, 2007
This is my site: http://shurl.net/2SU ,This is my site: http://shurl.net/2SUAnonymous
February 20, 2007
The comment has been removedAnonymous
March 13, 2007
I have followed your advice and comment out the call to "delete item" options in drop down menus. It works fine. I now would like to enable the "Delete Item" option just for Administrator. I do not want it to be visible for any other user. How do I put “IF” statement to limit it? Thanks. RubenAnonymous
March 15, 2007
<a href="http://cigarsworld.net/Quintero-cigars.php">Quintero cigars</a> are famous because of their specific aromas and strong flavors, which can be sweet or spicy depending on the cigar type.Anonymous
March 18, 2007
The comment has been removedAnonymous
March 18, 2007
best <a href="http://replica-watchesz.com">replica watch</a> retailer in the worldAnonymous
March 23, 2007
Lucy! Please call me,Lucy! Please call meAnonymous
March 24, 2007
Lucy! Please call me,Lucy! Please call meAnonymous
March 30, 2007
Very nice! I have some LJ with news, check this out: <a href= http://iwantubadlyz.livejournal.com >Newest news</a> <a href= http://annakubat.livejournal.com >Check this out</a> <a href= http://jackie_simpson.livejournal.com >livejournal</a>Anonymous
March 31, 2007
Very nice! I have some LJ with news, check this out: <a href= http://michelas.livejournal.com >My live journal</a> <a href= http://homerius.livejournal.com >Lastest news</a> <a href= http://johnyknoxw.livejournal.com >My live journal</a>Anonymous
April 02, 2007
Thank you ver much post it was very helpfull........................Anonymous
April 02, 2007
I mean Thank you very much for the post it was very much helpfullAnonymous
April 04, 2007
Your site is best look my site - <a href="http://freecal.brownbearsw.com/Magnarx">Magna rx</a>Anonymous
April 05, 2007
All <a href="http://replica-watchesz.com/Fendi-Watches.htm">Fendi watches</a> contain ETA Swiss movements and are water resistant to 100 feet.Anonymous
April 05, 2007
All <a href="http://replica-watchesz.com/Fendi-Watches.htm">Fendi watches</a> contain ETA Swiss movements and are water resistant to 100 feet.Anonymous
April 07, 2007
visit us, i could found very usefull informationAnonymous
April 13, 2007
<a href="http://muonline-info.blogspot.com">MU</a>-online info - gameplay, characters, maps..Anonymous
April 13, 2007
<a href="http://muonline-info.blogspot.com">MU</a>-online info - gameplay, characters, maps..Anonymous
April 24, 2007
http://yourvipsearch.info/replica-watchesAnonymous
April 30, 2007
<a href= http://dietary-supplements.piercing-shop.biz >dietary</a>Anonymous
April 30, 2007
<a href= http://dietary-supplements.piercing-shop.biz >dietary</a>Anonymous
May 03, 2007
Hello. I have problem with enter to this site via GPRS. Please, help me. Thanks! Best regards.Anonymous
May 28, 2007
. , , , , Wildhog, . , , , " "[url=http://saylormooyen.justfree.com].[/url] , . [url=http://saylormooyen.justfree.com][img]http://saylormooyen.justfree.com/tm.jpg[/img][/url]Anonymous
May 29, 2007
<a href= http://xigozy.angelfire.com >a business decision</a> <a href= http://fatoso.angelfire.com >a 5 drop forwards</a> <a href= http://pohofu.angelfire.com >aaway messages</a> <a href= http://gukogi.angelfire.com >a change of pace lyric loose lip sink ship</a> <a href= http://wedovu.angelfire.com >a way to carry on again</a>Anonymous
May 29, 2007
<a href= http://xigozy.angelfire.com >a business decision</a> <a href= http://fatoso.angelfire.com >a 5 drop forwards</a> <a href= http://pohofu.angelfire.com >aaway messages</a> <a href= http://gukogi.angelfire.com >a change of pace lyric loose lip sink ship</a> <a href= http://wedovu.angelfire.com >a way to carry on again</a>Anonymous
May 29, 2007
<a href= http://xigozy.angelfire.com >a business decision</a> <a href= http://fatoso.angelfire.com >a 5 drop forwards</a> <a href= http://pohofu.angelfire.com >aaway messages</a> <a href= http://gukogi.angelfire.com >a change of pace lyric loose lip sink ship</a> <a href= http://wedovu.angelfire.com >a way to carry on again</a>Anonymous
May 29, 2007
<a href= http://kehovi.angelfire.com >a recipe for salt and pepper prawns</a> <a href= http://galevi.angelfire.com >aa road watch dublin</a> <a href= http://tywysa.angelfire.com >a painted house book report</a> <a href= http://hetela.angelfire.com >aa arena dallas</a> <a href= http://gaxeku.angelfire.com >aardvark swimsuits</a>Anonymous
June 04, 2007
- , 3D , , . , , . Fold-Up, Pop-Up, Roll-up, Pos , , , , , , 3D - . http://pos-pr.ru/ e-mail: pos-pr@mail.ru
Anonymous
September 20, 2007
I don't see the "Add To My Links" menu item in the drop down menu of a document, does anybody knows why? My site is a Collaboration Portal and my library is a simple Document Library, thanksAnonymous
September 15, 2015
Good piece - I loved the specifics ! Does someone know if I can grab a sample 2012 GSA SF-424 form to work with ?