- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2023 07:54 AM - edited 06-06-2023 05:39 AM
Hi All,
I have a requirement to create a link in ritm form to download a file. When the user clicks on the link, it should download a file, and the form should stay on the same page.
For this, I created a UI action for the ritm table with the below code.
onclick -confirmDownload()
script:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 02:12 AM
your UI action should be client side and update script as this
No need to use action object
function confirmDownload() {
var URL = '/sys_attachment.do?sys_id=aec12b1b970321100408bde3f153affb';
var down = confirm("Do you want to download the file?");
if (down == true)
g_navigation.open(URL, '_blank');
}
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
06-01-2023 08:21 AM - edited 06-01-2023 08:22 AM
Hi @Nag9 ,
Please add the below line at end of your code, that should do the work.
// add this after redirectURL line
action.setReturnURL(current);
Please mark this correct and helpful if it solved your query and helpful alone if it lead you in right direction.
Mohit Kaushik
ServiceNow MVP (2023-2025)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2023 08:46 AM
Thanks for quick reply,
Still form is redirecting to other page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 01:04 AM
@Ankur Bawiskar Could you please help me on this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 02:12 AM
your UI action should be client side and update script as this
No need to use action object
function confirmDownload() {
var URL = '/sys_attachment.do?sys_id=aec12b1b970321100408bde3f153affb';
var down = confirm("Do you want to download the file?");
if (down == true)
g_navigation.open(URL, '_blank');
}
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