How can I download multiple attachments as single files instead of ZIP?

Tobias Persson
Tera Contributor

Hi community!

I would like to set up a UI Action that downloads all attachments. I know there is a functionality that does this downloading all files as a ZIP file. But that's not what I want. I need every file downloaded as is without having it in a ZIP file. 

Is that possible and how would I do that?

Thanks!

1 ACCEPTED SOLUTION

Hi,

can be done

1) create a form UI action which is client side

2) Client checkbox - true

3) Onclick - downloadAll()

4) Script:

Ensure your pop-up blocker is allowing the new tabs then only the files would be downloaded

function downloadAll() {

	var gr = new GlideRecord("sys_attachment");
	gr.addQuery("table_sys_id", g_form.getUniqueValue());
	gr.query();
	while(gr.next()) {
		window.open('/sys_attachment.do?sys_id='+gr.sys_id,"_blank");
	}
}

find_real_file.png

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

so every single file should be a zip file?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi,

thank you for taking time to answer my request.

And sorry, that's not what I meant. Let's assume I have 2 *.jpg and 1 *.pdf file attached to a record. I want them to be downloaded as 2 *.jpg and 1 *.pdf files and not as 1 *.zip.

I hope that clarifies my request.

Hi,

Still not clear.

2 files sample.jpg and inc.pdf -> should it be merged into 1 zip file?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi,

not sure how to describe it more detailed. I will try:

2 files sample.jpg and inc.pdf -> click "Download All" button -> do NOT merge files in a ZIP, instead simply download both files 

After the download the local download folder on my computer should contain both sample.jpg and inc.pdf.