Is it possible to change the sys_attachment URL in tearOffAttachment in Attachment dialog [attachment_entry]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2022 10:09 PM
Hi folks,
I am trying to change the URL in the Attachment [View] link which is constructed in UI Macro [attachment_entry], and have not found a way as it has not been visible for the modification.
A little bit background to explain why I am trying to do so: In my organisation, old attachments (let's say 90 days old) are archived and exported to a remote cloud storage called MS Azure, When a file is archived (uploaded to Azure) users still can access the attachments but the download process triggers a restoration process in the backend. This works perfectly fine when they click the Filename in the attachment list, but when clicking the [View] link, the Document Viewer would not be able to fetch the file, as technically this file no longer exists in system as sys_attachment record,
To overcome this issue, there is a custom Processer named u_sys_attachment_ext.do, instead of the OOB sys_attachment.do. The custom process checks to see if the file is archived, if so, performs a restoration process and presents the attachments to the end user.
My goal is to make a change to the OOB URL from "sys_attachment.do?sysparm_referring_url=tear_off&view=true&sys_id=5cb12527db781190404ba6bad396197d"
to
u_sys_attachment_ext.do?sysparm_referring_url=tear_off&view=true&sys_id=5cb12527db781190404ba6bad396197d
However, the UI macro tearOffAttachment function does not seem editable to me?
<a class="attachment view_${sys_attachment.sys_id}" click-on-enter="true" href="#" onclick="tearOffAttachment('${sys_attachment.sys_id}');" aria-label="${HTML:jvar_attachment_aria_label}">
${jvar_attachment_action_title}
</a>
Thank you for your attention and advice
- Labels:
-
Instance Configuration

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 12:00 AM
This might be a bit dodgy, but have you tried replacing the macro with your own one, using a custom function for onclick? I recall being able to override some of OOTB features this way, like UI pages, however this does not always work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2022 09:52 PM
Thanks for the response. I have tried to test custom JavaScript codes in the onClick="" block and have been able to control the link clicking behaviour with Java Script window.location library, however, this way does not look like the way tearAttachment function opens the pop-up dialog. There is also another way to achieve the same, that is to introduce a javascript function isArchived() which check to see if the attachment is archived or not.
- Make changes to line from
<a class="attachment view_${sys_attachment.sys_id}" click-on-enter="true" href="#" onclick="tearOffAttachment('${sys_attachment.sys_id}');" aria-label="${HTML:jvar_attachment_aria_label}">
To
<a class="attachment view_${sys_attachment.sys_id}" click-on-enter="true" href="#" onclick="if (!isArchived('${sys_attachment.sys_id}')) tearOffAttachment('${sys_attachment.sys_id}');" aria-label="${HTML:jvar_attachment_aria_label}">
I will have another go with it, and thanks again for your response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2023 12:43 AM
Hi Chen,
Are you able to update the URL in tearOffAttachment ?
Can you share more info if you have done
Thanks
Srini