- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 11:31 PM
I want to download some attachement of multiple records at once, Is this possible?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 09:52 PM
try this
function downloadAll() {
var selectedSysIds = g_list.getChecked();
var arr = selectedSysIds.split(',');
for (var i = 0; i < arr.length; i++) {
alert(arr[i]);
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id", arr[i]);
gr.query();
if (gr.next()) {
alert(123);
var url = '/sys_attachment.do?sys_id=' + gr.sys_id;
g_navigation.open(url, '_blank');
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 06:15 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 06:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 08:38 PM
It only can print one record sysid and123 can show , It seems window.open('/sys_attachment.do?sys_id=' + gr.sys_id, "_blank"); not worked
function downloadAll() {
var selectedSysIds = g_list.getChecked();
var arr = selectedSysIds.split(',');
for (var i = 0; i < arr.length; i++) {
alert(arr[i]);
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id", arr[i]);
gr.query();
if (gr.next()) {
alert(123);
window.open('/sys_attachment.do?sys_id=' + gr.sys_id, "_blank");
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 09:51 PM
Hi,
update as this
function downloadAll() {
var selectedSysIds = g_list.getChecked();
var arr = selectedSysIds.split(',');
for (var i = 0; i < arr.length; i++) {
alert(arr[i]);
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id", arr[i]);
gr.query();
if (gr.next()) {
alert(123);
var url = '/sys_attachment.do?sys_id=' + gr.sys_id;
g_navigation.open(url, '_blank');
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 10:05 PM
Hi , I tried your new code, when I selected three records ,and alert can show three records' sysid, But it only download an attachment of one record, why? thank you!
function downloadAll() {
var selectedSysIds = g_list.getChecked();
var arr = selectedSysIds.split(',');
alert(arr);
for (var i = 0; i < arr.length; i++) {
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_sys_id", arr[i]);
gr.query();
if (gr.next()) {
var url = '/sys_attachment.do?sys_id=' + gr.sys_id;
g_navigation.open(url, '_blank');
}
}
}