Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Changing SharePoint list item attachment to allow multiple files

I just got this email from a colleague saying he wants to upload Multiple Files as attachments to an item, and having to click add and confirm each and every one separately is quite annoying and time consuming.

So I wrote a little script that changes this behavior of the OOB file upload to allow multiple files selection.

Suprisingly, it works well with multiple files. there was only one part I had to fix, which was the label it shows before you save the item. It still shows the first file name only.

Here is the JavaScript code you can use to enable it on your system today. Just add this script in your new/edit item forms and it should work:

ExecuteOrDelayUntilScriptLoaded && ExecuteOrDelayUntilScriptLoaded(function(){
var oldShowPartAttachment = window.ShowPartAttachment;
var oldOkAttach = window.OkAttach;
window.OkAttach = function(){
var index = String(FileUploadIndex);
oldOkAttach();
var index2 = String(FileUploadIndex);
if(index2 === index)//it means OK fail.
    return;
var files = GetAttachElement(FileuploadString + index);
if(files && files.files.length > 1)//more than one file
var text = "";
for(var i=0;i text = text.slice(2);
document.getElementById("attachRow" + index).cells[0].innerHTML = text;
}
window.ShowPartAttachment = function(){
oldShowPartAttachment();
var index = String(FileUploadIndex);
var files = GetAttachElement(FileuploadString + index);
if(files)
files.multiple = true;
}}, "form.js");

Also, we will be adding this little script to a future release of our forms solution, so stay tuned for the update.

Let me know if you like it!


This post first appeared on Kwizcom Sharepoint Crm, please read the originial post: here

Share the post

Changing SharePoint list item attachment to allow multiple files

×

Subscribe to Kwizcom Sharepoint Crm

Get updates delivered right to your inbox!

Thank you for your subscription

×