Solved

SharePoint 2010: Add an upload button to a Document Set Welcome Page

Posted on 2013-05-27
2
536 Views
Last Modified: 2013-05-28
I am trying to add an 'Upload Documents' button onto onto the welcome page of a Document Set.
I found the following code at: http://sharepointaddict.blogspot.com.au/2012/10/add-upload-document-button-to.html

However when I run it, the modal window that pops up gives a 'file Not Found' error with the modal url of http://intranet/functions/it/testbed/Contract%20Review/Forms/_layouts/Upload.aspx?List=undefined&RootFolder=undefined&IsDlg=1&IsDlg=1

I added the code to a content editor webpart on the welcome page design.

Any ideas?

     
  <script src="/functions/it/testbed/SiteAssets/jquery-1.10.0.min.js" type="text/javascript"></script><script src="/functions/it/testbed/Contract%20Review/Forms/_layouts/SP.UI.Dialog.js" type="text/javascript"></script><script src="/functions/it/testbed/Contract%20Review/Forms/_layouts/SP.UI.Dialog.debug.js" type="text/javascript"></script><script type="text/javascript">
      
     //Using this to control when my script executes - don't want the script to load //on form load but on form click. I call this function in my runCode function  
     //below and then call the runCode function in my Upload Document's onclick event  
     $(document).ready(function(){  
     SP.SOD.executeOrDelayUntilScriptLoaded(initialize,'SP.js');  
     SP.SOD.executeOrDelayUntilScriptLoaded(test,'SP.js');  
      });  
     //takes the querystring from the first query string parameter in the Document Set //url to the last then splits it into an array using the ampersand (&) as the delimeter  
     function getUrlVars() {  
       var vars = {};  
       var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {  
         vars[key] = value;  
       });  
       return vars;  
     }  
     //Using the function to get the values we will use to obtain the url of the //upload document function dynamically  
     var listID = getUrlVars()["List"];
     var rootFolder = getUrlVars()["RootFolder"];  
     //This function opens up the form in modal dialog mode  
     function openDiaForm()  
     {    
       var diaOptions = SP.UI.$create_DialogOptions();    
       diaOptions.url = 'http://intranet/functions/it/testbed/Contract%20Review/Forms/_layouts/Upload.aspx?List='+ listID + '&RootFolder=' + rootFolder + '&IsDlg=1';    
       diaOptions.width = 800;    
       diaOptions.height = 600;    
       diaOptions.title = "Upload Document Form";  
         diaOptions.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);  
       SP.UI.ModalDialog.showModalDialog(diaOptions);  
     }  
     //The function refreshes the content of the Document Set Welcome Page after the Upload Document modal dialog box has been closed  
     function CloseCallback(result, target) {  
         location.reload(true);  
       }  
     function runCode() {  
       var x = ExecuteOrDelayUntilScriptLoaded(openDiaForm, "sp.js");  
     }  
      </script><div class="ms-uploadbtnlink"><button onclick="runCode();" type="button" value="Run Code">&#160;<span>Upload Document</span></button> </div>

Open in new window

0
Comment
Question by:techvagabond
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
techvagabond earned 0 total points
ID: 39200498
Moved the vars down into the next slab and I had the wrong location of the Upload.aspx
diaOptions.url = 'http://intranet/functions/it/testbed/Contract%20Review/Forms/_layouts/Upload.aspx?List='+ listID + '&RootFolder=' + rootFolder + '&IsDlg=1';
to
diaOptions.url = 'http://intranet/functions/it/testbed/_layouts/Upload.aspx?List='+ listID + '&RootFolder=' + rootFolder + '&IsDlg=1';
0
 
LVL 4

Author Closing Comment

by:techvagabond
ID: 39200501
corrected the location of the upload.aspx
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now