- 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-02-2023 04:11 AM
Awesome Ankur, its working.
without action object - if I click the link file is not downloading.
With action object - it is working perfectly.
Here is the code:
function confirmDownload() {
var URL = '/sys_attachment.do?sys_id=e33c48b32f4321108bc8ad6df699b631';
var down = confirm("Do you want to download the file?");
if (down == true)
g_navigation.open(URL, '_blank');
}
Is this List v2 Compatible that should be enabled in the form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2023 04:35 AM
you are doing this in native view right?
it should work fine.
Can you share your latest script and UI action configuration screenshot along with the form where you are testing this?
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-02-2023 06:49 AM
Here is the snippet of the code
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2023 08:19 PM
then it should work fine.
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-05-2023 06:39 AM
Hi Ankur,
There is confusion about the requirement. I got clarity today.
The UI action should fetch the fields or variable data from the form to Excel once the user clicks the link and then downloads it.
How can we do that