Check Document has been uploaded
Hi
I have a form for users to upload set types of analysis documents prior to a meeting being held.
Rather than use the documents sub-list, this form also acts as a checklist to make sure that the user uploads the correct documents.
I have the type of document to upload with a tick box and an attach button. The button instigates an upload document action which all works as expected. I have the related tick box which is set to true when the user exits the upload. However this is still set to true even if the user hits cancel without uploading a file.
Is there a way, script or otherwise to determine that the user did actually attach a document ?
-
Hi David Beckinsale,
for this scenario I would implement the upload file function by myself and set the checkbox using jQuery if the result is 1. If you press cancel on the upload dialog, the result will be 0.
function OpenModalDialogFileUploadSetCB() {
var options = {
url: '/sites/test_mwa/demo/_layouts/15/Upload.aspx?List=2e066082-0ee1-47c2-af6c-b67784fd4cff',
title: 'Upload Document',
allowMaximize: false,
showClose: false,
width: 800,
height: 600,
dialogReturnValueCallback: function(dialogResult,returnValue){
if(dialogResult==1){
jQuery("span input[title=File1Submitted]").prop("checked", true);
};
}
};
SP.UI.ModalDialog.showModalDialog(options);
}
OpenModalDialogFileUploadSetCB();BR Matthias
0 -
Hi Matthias,
Thank you so much, works really well.
I would also like to set a target folder as the documents all sit in their own subfolders off the document root. The option is in the original Upload Document action as target folder. How would i implement this, can i use RootFolder as an option or would i need to include this as part of the url after the guid ? I will need to pass in the [[ID]].
Thanks again,
0 -
Hi David Beckinsale,
you're welcome.
Yes you can use the RootFolder Parameter in the url like this:
var currentID = [[ID]];
function OpenModalDialogFileUploadSetCB() {
var options = {
url: '/sites/test_mwa/demo/_layouts/15/Upload.aspx?List=db313434-7538-4156-9bad-eff7e4103b60&RootFolder=%2Fsites%2Ftest_mwa%2Fdemo%2FContactDocuments%2FContacts-'+currentID,
title: 'Upload Document',
allowMaximize: false,
showClose: false,
width: 800,
height: 600,
dialogReturnValueCallback: function(dialogResult,returnValue){
debugger;
if(dialogResult==1){
jQuery("span input[title=File1Submitted]").prop("checked", true);
};
}
};
SP.UI.ModalDialog.showModalDialog(options);
}
OpenModalDialogFileUploadSetCB();BR Matthias
0 -
Hi Matthias,
Thank you. That works great.
I've just uploaded it to my customer site, but their site url is slightly different after the /sites/ folder and and I get the something went wrong message. Can anything be done about this or will I have to use their url or would I be better off re-deploying it so that both url's are the same.
Thanks again.
0 -
Hi David Beckinsale,
therefore just make the rootfolder dynamic as well to make it work everywhere (specifically check line 1 & 4):
var encodedRootFolder = encodeURIComponent([[@Web.ServerRelativeUrl]]+"/ContactDocuments/Contacts-"+[[ID]]);
function OpenModalDialogFileUploadSetCB() {
var options = {
url: '/sites/test_mwa/demo/_layouts/15/Upload.aspx?List=db313434-7538-4156-9bad-eff7e4103b60&RootFolder='+encodedRootFolder,
title: 'Upload Document',
allowMaximize: false,
showClose: false,
width: 800,
height: 600,
dialogReturnValueCallback: function(dialogResult,returnValue){
if(dialogResult==1){
jQuery("span input[title=File1Submitted]").prop("checked", true);
};
}
};
SP.UI.ModalDialog.showModalDialog(options);
}
OpenModalDialogFileUploadSetCB();BR Matthias
0 -
Thank you Matthais.
0
Please sign in to leave a comment.
Comments
6 comments