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 (64)

  1. Gilles Sylvestre says:

    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.ca

  2. Ron says:

    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.

    Ron

  3. Ron says:

    (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.

    Ron

  4. 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]

  5. 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]

  6. 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]

  7. Alex says:

    http://www.mscracks.com – software cracks, serial numbers, keygens, patches, cd keys, activation codes

  8. sausau says:

    Excellent browsing have the to

  9. 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]

  10. Thank you for this great post about <a href="http://tracynolan.50megs.com/breast-augmentation.html"”>http://tracynolan.50megs.com/breast-augmentation.html" title="breast augmentation">breast augmentation</a> and [URL=http://tracynolan.50megs.com/breast-augmentation.html]breast augmentation[/URL]

  11. info says:

    Excellent browsing have the to

  12. gratis says:

    Excellent browsing have the to

  13. gratis says:

    Excellent browsing have the to

  14. Besid,Besid says:

    Very good project! <a href= http://www.debtconsolidation.newov.info >debt consolidation</a> <a href= http://www.badcreditloan.newov.info >bad credit loan</a>

  15. gratis says:

    Excellent browsing have the to

  16. Tonik says:

    Well, your site is very good, good news and design…! ))) Happy Christmas! SmilerMan.

  17. Ocis,Ocis says:

    Very nice resources!<a href= http://betting.ggfix.com >betting</a> <a href= http://wagering.ggfix.com >wagering</a>

  18. midi says:

    Excellent browsing have the to

  19. sarde,sarde says:

    Beautiful site!,Beautiful site!

  20. 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 luck

  21. Marsha says:

    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]

  22. italiitali says:

    Excellent browsing have the to

  23. italiitali says:

    Excellent browsing have the to

  24. appa[3!] says:

    Excellent browsing have the to

  25. Nita says:

    Hi ,

    I am having a lil problem with a webpart on SP07.

    I have used a Page Viewer Webpart to display a classic ASP Page. I would like to change the behaviour of this WebPart when ‘Edit’ is clicked and ‘Modify shared webpart’ is selected. I would like it to display another ASP Page. Is this possible? Or else is it possible to add another option onto the drop down that comes when clicking on ‘Edit’ of the webpart?

    Scratching my head.

  26. Ruben says:

    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.

    Ruben

  27. John says:

    <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.

  28. Doxycycline says:

    Re: <a href=http://medjetnet.info/doxycycline/buy-doxycycline.html>Doxycycline</a>”>http://medjetnet.info/doxycycline/buy-doxycycline.html>Doxycycline</a> is used to treat bacterial infections, including pneumonia and other respiratory tract infections; Lyme disease; acne; infections of skin, genital, and urinary systems; and anthrax (after inhalational exposure). It is also used to prevent malaria. Doxycycline is in a class of medications called tetracycline antibiotics. It works by preventing the growth and spread of bacteria. Antibiotics will not work for colds, flu, or other viral infections.

    [URL=http://medjetnet.info/doxycycline/buy-doxycycline.html]buy doxycycline[/URL]|

  29. Peter says:

    best <a href="http://replica-watchesz.com">replica watch</a> retailer in the world

  30. Lucy! Please call me,Lucy! Please call me

  31. Lucy! Please call me,Lucy! Please call me

  32. Britneypdezy says:

    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>

  33. Britneygctfm says:

    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>

  34. Sukumar says:

    Thank you ver much post it was very helpfull……………………

  35. sukumar says:

    I mean Thank you very much for the post it was very much helpfull

  36. Peni says:

    Your site is best look my site – <a href="http://freecal.brownbearsw.com/Magnarx">Magna rx</a>

  37. Rick says:

    All <a href="http://replica-watchesz.com/Fendi-Watches.htm">Fendi watches</a> contain ETA Swiss movements and are water resistant to 100 feet.

  38. Mister says:

    All <a href="http://replica-watchesz.com/Fendi-Watches.htm">Fendi watches</a> contain ETA Swiss movements and are water resistant to 100 feet.

  39. estate says:

    visit us, i could found very usefull information

  40. Anne says:

    <a href="http://muonline-info.blogspot.com">MU</a>-online info – gameplay, characters, maps..

  41. bloggerdad says:

    Hello.

    I have problem with enter to this site via GPRS.

    Please, help me.

    Thanks!

    Best regards.

  42. Anyutka-1985 says:

    .  ,   ,     ,   ,   Wildhog,

     .      ,    ,  ,

          " "[url=http://saylormooyen.justfree.com].[/url]

    ,  .

    [url=http://saylormooyen.justfree.com][img]http://saylormooyen.justfree.com/tm.jpg[/img][/url]

  43. Papaydl says:

    <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>

  44. Papaydl says:

    <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>

  45. Papaydl says:

    <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>

  46. Papayuv says:

    <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>

  47. maxgood3 says:

    –      ,

    3D    , , .  ,

       ,   .

      Fold-Up, Pop-Up, Roll-up, Pos ,  

     ,    ,  

    , ,      

    , 3D     –  .

    http://pos-pr.ru/

    e-mail: pos-pr@mail.ru

  48. Jerome Labbe says:

    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, thanks

  49. virgie says:

    Good piece – I loved the specifics ! Does someone know if I can grab a sample 2012 GSA SF-424 form to work with ?