- 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 01:43 AM
Hi , I followed the steps above to create the ui page, but how to test it? I don't see there is any difference.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 02:03 AM
@Ankur Bawiskar , can you help me with this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 02:14 AM
Hi,
multiple records of same table right?
why not create list choice UI action and iterate over all the sysIds and download it
I shared solution for something similar 3 years ago but that is not required in your case
For your case you can use something similar
1) List choice - True
2) Client - True
3) Onclick - downloadAll()
4) Script
function downloadAll() {
var selectedSysIds = g_list.getChecked();
var arr = selectedSysIds.split(',');
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()) {
window.open('/sys_attachment.do?sys_id='+gr.sys_id,"_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 02:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2022 02:59 AM