Monday, August 13, 2012

Remove “+ Add document" from a SharePoint 2007/2010 Document Library

In this post , i will show you how to hide the "+ Add document " option from the SharePoint Library in SharePoint 2010.

I will explain you with the help of a scenario :

There are some times which we don't need the "Upload Option" in library just due to restrict the user not to upload any file/document.

 In my previous post i have show you the ways to hide the "Upload Button" in ribbon.

Now i will show you ,how to hide the "+Add document" option from library :

Suppose the below is the document library where we want to hide the "+Add document" option :


We can achieve this by the following methods
1.   Editing the WebPart
2.   Using SharePoint Designer(CSS)
3.   Using J Query
4.   By Permission level(Default)

1. Editing the WebPart
Go to Edit WebPart -> Tool bar Type -> Select NoToolBar option which will hide the Add Document option
2. Using SharePoint Designer(CSS)
Go to the designer and edit the page/webpart where you want to hide. Search for class=”ms-addnew” and change the style to Style=”display:none”
3. Using J Query
Add a CEWP and link the following J-Query in it and hide the CEWP webpart

$(document).ready(function()

{

$(‘#WebPartWPQ2 .ms-addnew’).hide();

});

4. By Permission Level (Default)
We can set the permission level for the document library to read only and hence the user with read only option in the SharePoint site will not see this option.

I have done by using the 1st Option. Try it.

Thanks
Any Question/Suggestion ?

Tuesday, August 7, 2012

Disable the Upload Button of a Document library in SharePoint 2010

Disable the "Upload" button of a Document library in SharePoint 2010

There are two ways to disable the upload button :

1st way :

Open your site using SharePoint Designer.  Once opened, navigate to your Library and edit your default view.  (All Files -> Your Library -> Forms -> Your View.aspx, right click and select Edit File in Advanced Mode)

At the bottom of the screen you will see three options Design, Split, and Code.  Select the Split option.

In your code window, locate the <asp:Content ContentPlaceHolderId=”PlaceHolderMain” runat=”server”>  tag.
Now, scroll down and find the closing </asp:Content> tag.  Insert a line above the closing tag.  Place the following code into that newly created blank line.

<style type="text/css">
 #Ribbon\.Documents\.New\.AddDocument-Large
{
display:none;
#Ribbon\.Library\.Actions\.OpenWithExplorer-Medium
{
display:none;
}
</style>

Click save, then refresh your page.  The Documents tab should now be missing the Upload Document button and the Library tab should be missing the Open with Explorer button.

Using IE, you can find the ID’s of the other buttons in the ribbon.  With your View open in IE, click F12.  Once Developer Tools finishes loading, select Find from the top menu, then click on Select Element by Click.  Back in IE, click on the button you want the ID of.

2nd Way :


I would like to show this by giving an example :-

Suppose i have a document library that uses Infopath form it is termed as Form Library.

When a new form is submitted , a series of workflows are triggered and corresponding task is assigned , etc. I had an issue where workflows were getting started multiple times and the task are also assigned  , and generally causing chaos.

I traced the issue, that users were not using the "New Document" button to create a form,but were also saving old forms and re-uploading them using the "Upload" button which results in duplicate files and duplicate workflows etc.

I resolved the issue by simply removing the upload button from the edit.aspx page in each library using the SharePoint Designer.

Steps to do so :

1. Click on the SharePoint Designer to open the edit.aspx page.

2. In Design view right click the List View Web part and select the XSLT data View from the context menu.

3. Switch to split view and locate the "New" button, and you will see the XSLT code.

4. Set the "td " visibility as "hidden" as shown below :








In order, to prevent an unsightly 'blank space' in the menu, I moved the location of the hidden button to the last button on the right of the menu. 

Now users have to use the "New" button to create a new document and cannot use the upload button.
Keep in mind that you'll have to do this for each view that the users have access to, as each view has it's own page that will need editing. 
Thanks

Any Question/Suggestion ??