Sharepoint 2013 Upload Document Hide Destination Folder
If you take ever used SharePoint, you know what I'yard talking well-nigh. Yous have a file you want to upload into a document library. Fantastic. You click Upload document from the ribbon, and get the dialog box below.
You accept the option to "overwrite existing files" and it is checked by default. You desire this under normal circumstances. You want to have versioning turned on in the library, so when you lot exercise overwrite an existing file, it retains the previous copy for prosperity and all forms of natural disasters.
Still, I had a customer (and there are others out there, y'all know who you lot are) who wanted the ability to have this setting unchecked past default for a specific library.
The Like shooting fish in a barrel Answer
This is where everyone on the internet gives the like shooting fish in a barrel respond. This reply is assuming you are on-premise of course (not using SharePoint Online in Office 365 or another hosting version). The first thing to empathise is that the dialog box you see ("Upload Document") is the same file that is used for every single library in SharePoint!
So y'all are directed to get to the upload.aspx file in the xiv hive (2010) or 15 hive (2013). This file contains the actual lawmaking of the dialog box folio. As directed, you crack open the file and go to the line that contains "Overwritesingle". This is line 248 for me. You change the Checked="true" to Checked="imitation". Save your file, refresh, and BLAM it's unchecked.
Corking! Except that remember I mentioned this one file is used everywhere? Then guess what, it's unchecked everywhere! That's actually non what we desire. We merely desire this on One library.
Target a Single Library
If your goal is to merely target 1 library, don't perform the above steps. There are multiple blogs and forums out there that offering solutions. Basically you can put some JavaScript in your master page that tin target a specific library. This weblog has a good case of how to practise this.
What yous practise is basically identify this code in your master page, and the code checks if the library tied to the open dialog box matches the i you desire by GUID. If information technology matches, it can hibernate or uncheck the control.
I just wanted to uncheck it, so I just used this line after the if statement:
$(
"input[type='checkbox']"
).attr(
'checked'
,
fake
);
You get dorsum to your library, and yous click the "Add together document" link, and it works! It's unchecked. Y'all think your job is done and good to go. Alas, you're non. And this brings me to the point of this web log.
This should work on 2010, 2013 and 2016. This should even work in SharePoint Online. One different possibility of not using the master page is JavaScript Embed / Injection.
One More than Step
Every bit I mentioned, this fixes ONLY if you click the "Add Certificate" link from the bottom of the library. When yous click File –> Upload Document from the ribbon, estimate what. Information technology's checked once again. What's going on? Subsequently some javascript debugging, we figured out why. I'll spare you the debugging, but information technology boils down to a text compare mismatch.
The JavaScript checks the context of the URL of the dialog box, and looks for the GUID. This is the line:
if
(location.href.indexOf(
'A9A5E8AC-3FC6-4279-AE8D-A7C8B9688209'
) >= 0)
When you click Add document from the bottom of the page, it matches considering the URL the code checks is in the same format (encoded):
http://<sharepoint URL>/site/_layouts/Upload.aspx?List={8CBCBFB4-B45D-43BD-A261-4BC3D8A09CC2}&RootFolder=&IsDlg=one
Because this is encoded, it works. Now let's look at the format when loaded from the Upload Document ribbon push button:
http://<sharepoint URL>/site/_layouts/Upload.aspx?List=%7B8CBCBFB4%2DB45D%2D43BD%2DA261%2D4BC3D8A09CC2%7D&RootFolder=%2Fsite%2FShared%20Documents&Source=http%3A%2F%2Fsharepoint%2Fsite%2FShared%20Documents%2FForms%2FAllItems%2Easpx&IsDlg=one
Well strike 1 for Microsoft for consistency. Notice how the GUIDs are non encoded, meaning ugly raw HTML. Ok at present we know why, and it's an piece of cake set up.
At that place are multiple ways and tin vary depending on your preference in JavaScript. The quickest way was just to make the if argument an OR statement like this:
if ((location.href.indexOf(8CBCBFB4-B45D-43BD-A261-4BC3D8A09CC2') >= 0) || (location.href.indexOf(8CBCBFB4%2DB45D%2D43BD%2DA261%2D4BC3D8A09CC2) >= 0))
Of course be sure to supersede the GUID with the ID of YOUR library. NOW our solution is fully functional!
Later y'all're done congratulating yourself, be sure to cheque out our upcoming events at https://events.c5insight.com. There are some great free webinars on SharePoint and other topics coming upwardly for sure. But I want to phone call out that you've merely got a few 24-hour interval left to get the lower cost of our Concern Workshop: Building A Roadmap for Intranet Collaboration Success. Nosotros promise to see you in that location!
Source: https://www.c5insight.com/Resources/Blog/tabid/148/entryid/674/one-missing-step-to-uncheck-overwrite-existing-files-in-sharepoint.aspx
0 Response to "Sharepoint 2013 Upload Document Hide Destination Folder"
Post a Comment