O365: Uncheck the Overwrite checkbox

We have a customer who are planning on putting a lot of documents into a Library in SharePoint. These documents will be uploaded, by hand, and are nearly always the ‘final’ version of the document. Given the number of documents in the library, the plan is to find them again using their metadata, which seems like a good idea.

However, there’s a catch – what if someone has uploaded a document with that filename already?

It’s possible. Unfortunately, unlike when you save something from Office, by default during upload there is no warning that the file already exists. There is a checkbox to allow files to be overwritten as a new version, but this is checked by default:

checkbox

This is unfortunate. By default, our users could accidentally overwrite a file that had been uploaded with that filename already. This is less than ideal.

What would be good is if the checkbox were unchecked by default. Unfortunately, there is no setting for this. So I started considering options.

I thought about replacing the upload page, but this is Office 365, and the upload page is in the LAYOUTS directory, so I can’t supply my own, or modify the existing one with SharePoint Designer. What I might be able to do is uncheck the checkbox with JavaScript. But how do I get this into the page? It’s a LAYOUTS page, I can’t modify it.

Well, the upload form does use a master page, so I decided to try that – I added the following code into the master page:

<script type="text/javascript" src="/Style%20Library/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		if(window.location.pathname.indexOf("/_layouts/15/Upload") != -1) {
			$("input[type='checkbox']").attr('checked',false);
		}
	});
</script>

This code uses JQuery. When the document has loaded and is ready, it checks to see if the page is a) in layouts, and b) has a filename starting ‘Upload’. This is because there are 2 upload forms (Upload and UploadEx) in _layouts. If the page is an upload form, we look for a checkbox, and uncheck the control. And this works nicely; our page loads, and then the JavaScript in the master page finds the checkbox, and unchecks it.

It’s just a shame that I have to do this; SharePoint really ought to have a setting to leave it unchecked by default, or at least warn the user that a file of that name already exists in a given location.

Advertisement
O365: Uncheck the Overwrite checkbox

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.