SharePoint Experts, Information Architects, Expert Witness

SICG provides a broad array of business and technology consulting from architecture to design to deployment of global systems with a focus on surfacing data in the enterprise. We focus on the "How", not just the possible. Contact me direct: or call 704-873-8846 x704.

Search This Blog

Thursday, March 3, 2016

Using the Upload Document Button outside of the Document Center (SP 2013)

Like me, you've probably wanted to use the Upload Document button from the Document Center in another site type:
While I've done this in 2010, there are some minor changes in 2013 to the script to get it to work. Using the 2010 solutions, you will find that once a page it published, the script will not work!

Here's the actual solution for 2013 - first, create a text file and add the following code (note the URL you have to set - also, I used 'Documents' - specify the proper library name):

<script type="text/javascript">// <![CDATA[
var navBarHelpOverrideKey = "wssmain";
function OpenNewFormUrl(url)
var options = {};
SP.SOD.executeFunc('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', function() {
SP.UI.ModalDialog.commonModalDialogOpen(url, options, null, null);
// ]]>
   <button onclick="javascript:OpenNewFormUrl(&#39;[URL TO YOUR SITE]/Documents/Forms/upload.aspx&#39;);return false;">
         <img alt="Upload a Document" src="/_layouts/15/images/uploaddoc.png?rev=23" style="vertical-align: middle;"/>&#160;<span>Upload a Document</span></nobr> </button></div>

Upload the file to a library in SharePoint and copy the link (shortcut). Navigate to a page and add a Content Editor Web Part or Script Web Part - edit the web part settings and paste in the link to the text file. Save the part settings and you are ready to go.

NOTE: Don't edit the CEWP source - SharePoint will 'rewrite' the code and while it might work, more often it doesn't!

No comments: