Dec 26, 2011

How to hide the download a copy option (Context Menu) in the Document Library

In the document library we have an option of downloading the document as shown below.

If the user wants to hides or remove this option for all the users. The following steps will explain the same.
1. First locate the following path C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033
2. Find the file named “CORE.js”. This is the file which will run the scripts downloading option for the document library.
3. Open the core.js file in best .js file editor and search for the function 
        AddSendSubMenu(m,ctx)
        Where you can see
        menuOption=CAMOpt(sm, L_DownloadACopy_Text, strAction, "");
        menuOption.id="ID_DownloadACopy";
These lines of code which will display text "Download A Copy" and call the menu operation.
So, comment the code and save the file.
4. Now when you search the context menu (Download a copy) option will be hidden as shown in the following figure.

Disadvantage
The above solution will affect all the document libraries of the SharePoint Server.
So, how to do it a particular document library or one web collection?
Hence the solution is as follows:
1. Open the default.master page in the designer.
2. Locate the core.js in the master page
<SharePoint:ScriptLink language="javascript" name="core.js"                  Defer="true" runat="server"/>
3.   So we can create our own (with the modifications as shown above) .js file (example named customcore.js) and save it in the following location
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033
4.   Now we can add the reference as shown below.
<SharePoint:ScriptLink language="javascript" name="customcore.js" Defer="true" runat="server"/>
5.   Now it won’t affect all the document libraries in the SharePoint server.

Bingo. We are done. We have restricted users to download the documents from the SharePoint Document library.


0 comments:

Post a Comment

Dear Readers,

I LOVE to hear from you! Your feedback is always appreciated. I will try to reply to your query as soon as possible.

1. Make sure to click the "Notify me" check box at the right side to be notified of follow up comments and replies.
2. Please Do Not Spam - Spam comments will be deleted immediately upon review.