- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 09:25 AM
Hi,
I have created the workspace UI action form button. I want to download the attachment from the URL when the user clicks on it but then return to the same workspace form. It is downloading the attachment but then it keeps on loading instead of staying in the same form.
function onClick(g_form) {
var redirectURL='/nav_to.do?uri=sys_attachment.do?sys_id=eb8b1a6f8714e21044e031983cbb35b4';
//top.window.location = redirectURL;
var win = top.window.open(redirectURL, '_blank');
win.focus();
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 07:11 AM
try this
Also did you check in different browsers? is auto download enabled in browser?
function onClick(g_form) {
var redirectURL='/sys_attachment.do?sys_id=eb8b1a6f8714e21044e031983cbb35b4';
//top.window.location = redirectURL;
open(redirectURL, '_self');
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2025 11:24 PM
Try to remove "_blank" from the code and try:
function onClick(g_form) {
var redirectURL='/nav_to.do?uri=sys_attachment.do?sys_id=eb8b1a6f8714e21044e031983cbb35b4';
//top.window.location = redirectURL;
var win = top.window.open(redirectURL, '');
win.focus();
}
✔️ If this solves your issue, please mark it as Correct.
✔️ If you found it helpful, please mark it as Helpful.
—
Shubham Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2025 11:30 PM
try this
function onClick(g_form) {
var redirectURL='/nav_to.do?uri=sys_attachment.do?sys_id=eb8b1a6f8714e21044e031983cbb35b4';
//top.window.location = redirectURL;
var win = top.window.open(redirectURL, '_self');
win.focus();
}
OR
function onClick(g_form) {
var redirectURL='/nav_to.do?uri=sys_attachment.do?sys_id=eb8b1a6f8714e21044e031983cbb35b4';
//top.window.location = redirectURL;
open(redirectURL, '_self');
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 06:31 AM
Hi @Ankur Bawiskar ,
Thanks for your reply. I tried both the codes but I am facing the same issue. Attachment downloading but the page keeps on loading.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-24-2025 06:42 AM
did you try with small file size?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader