How to download attachment in same window

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-21-2024 11:38 PM
Hello Team,
There is one attachment variable in the record producer
when the user clicks on the hyperlink(Download template here), the template gets downloaded (the form remains opened), no additional tabs should appear.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-22-2024 12:28 AM
Hello,
From SN OOB, the attachment variable always opens in a new tab since it’s designed to download or view the attachment. Since loading in current page might reload the form or pop up with “changes you made will be remoed”.
However, Customization is possible, but it depends on how important the use case is.
Try out this Client script onLoad:
function openAttachmentInSameTab(attachmentSysId) {
attachmentSysId = xyz //get this via a new ScriptInclude (GlideAjax call) > getRecentSysID based on orderByDesc(‘sys_created_on’) with setLimit(1) on the Attachment table.
var attachmentURL = '/sys_attachment.do?sys_id=' + attachmentSysId;
window.location.href = attachmentURL;
}
This is an overhead to the system, but depends on customer requirements.
If my response proves useful, please mark it "Accept as Solution" and "Helpful". This action benefits both the community and me.