So recently a customer had an issue where whenever a user attempted to Upload a document, complete some MetaData fields and click ‘Save’ or ‘Check In’, instead of the form closing and the document being added to the library the browser attempted to Open the document and left them in the form, rather than redirecting them back to the library.
Here is an example of what I mean. When using either the ‘Upload Document’ button in the ribbon, or using the ‘Add Document’ link that sits just under the library everything works fine as per the following screenshots:
However, sometimes these methods are hidden from the users and the designers do not like these default options with their branding and want to provide their own link/button to for the users. The temptation is to simply copy the shortcut link from the already existing Add Document link, and use this as the Upload link in their button. Here is what it looks like:
I have used this in my example and the text HERE has this link. When I attempt to add a document this way I will not get the same result as you can see from the following screenshot when I attempt to add another document by clicking this:
To avoid this behaviour and still provide your own link/button we need to do the following. On the page where the library is right click in your browser and view the source code of the page. You are looking for the following lines of code:
The easiest way to locate this is to CTRL F and look for <a class=”ms-addnew” id=”idHomePageNewDocument”
Copy the equivalent code from your source into a new blank text file called “UploadDocument.txt” (or whatever you want) and save this file to your desktop. Upload this file into SharePoint (location is not important, I put mine in the Site Assets library).
Next Add a Content Editor Web part to the page, edit the Web Part and in the Web Part options add a Content Link that points to this text file.
When you now click on the link the document will be uploaded successfully.