Form button to download all attachments for all related records of REQUEST
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-04-2022 02:50 AM
can we create a form button on the REQ form that will download anything attached to the REQ, any related RITM and any SC_TASK beneath those RITM
I have tired with below script in UI action and i can download the attachment from request table or its related RITM or SC_TASK, i cannot download all attachment at once
can anyone help with this issue !
gs.setRedirect('/download_all_attachments.do?sysparm_sys_id=' + current.sys_id);
gs.addInfoMessage('hi');
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.sys_id);
gr.query();
while (gr.next()) {
gs.setRedirect('/download_all_attachments.do?sysparm_sys_id=' + gr.sys_id);
var grm = new GlideRecord('sc_task');
grm.addQuery('request', current.sys_id);
grm.query();
while (grm.next()) {
gs.setRedirect('/download_all_attachments.do?sysparm_sys_id=' + grm.sys_id);
}
}
Regards
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-04-2022 03:16 AM
Hey,
Can you please try using gs.setRedirectURL('')?
Please mark this helpful if it answers your question
Thanks ,
Mohith Devatte.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-04-2022 05:27 AM
Hi,
Thanks for your reply. I tried as you said but still facing the same issue. Any other possible ways to achieve it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā07-04-2022 03:47 AM
Hi,
please make your UI action as client side
Client checkbox - True
Onclick - downloadFile()
Script
function downloadFile(){
var reqUrl = '/download_all_attachments.do?sysparm_sys_id=' + g_form.getUniqueValue();
g_navigation.open(reqUrl, '_blank');
var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.sys_id);
gr.query();
while (gr.next()) {
var ritmUrl = '/download_all_attachments.do?sysparm_sys_id=' + gr.sys_id;
g_navigation.open(ritmUrl, '_blank');
var grm = new GlideRecord('sc_task');
grm.addQuery('request', current.sys_id);
grm.query();
while (grm.next()) {
var scTaskUrl = '/download_all_attachments.do?sysparm_sys_id=' + grm.sys_id;
g_navigation.open(scTaskUrl, '_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
ā07-04-2022 05:25 AM
Hi
Again facing the same issue that only the request table attachment is getting downloaded. But the requirement of downloading all the attachments from its related ritm and task table isn't working as expected. Referring to one of the already existing thread, i tried using window.open as mentioned by you, but still getting the same result.
Any other modifications needed? Kindly help!
Regards,