- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 07:47 AM
Hello,
I currently have a requirement to configure a button that allows for downloading all attachments added within in a ticket form on the Service Portal, see photo below
I know where to make these edits, but as to how I am unsure and inexperienced within the Service Portal. Any ideas?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 08:23 AM
Hu, never looked into this before but there is a button on the platform UI Attachments dialog to download all attachments. This is the function the button calls.
function downloadAllAttachments() {
var downloadUrl = window.location.protocol + '//' + window.location.host + '/download_all_attachments.do?sysparm_sys_id=' + attachmentParentSysId
+ "&sysparm_this_url=" + getCurrentPageURL();
window.location = downloadUrl;
}
So it looks like you can just add a button to your widget and then open a new tab/window to the above URL and you are all set.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 08:23 AM
Hu, never looked into this before but there is a button on the platform UI Attachments dialog to download all attachments. This is the function the button calls.
function downloadAllAttachments() {
var downloadUrl = window.location.protocol + '//' + window.location.host + '/download_all_attachments.do?sysparm_sys_id=' + attachmentParentSysId
+ "&sysparm_this_url=" + getCurrentPageURL();
window.location = downloadUrl;
}
So it looks like you can just add a button to your widget and then open a new tab/window to the above URL and you are all set.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 11:38 AM
Hi there Drew,
Thank you, this helps a lot! How would I configure the button? How would ServiceNow know when the button is clicked to trigger the function? Sorry I'm very new to this.
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 11:45 AM
You are going to have to update the widget and add a button. Its very similar to any web page, there is an onClick event but since its Angular you us ng-click.
To find out which widget to update you can ctrl+right click on the area you want the button to get a menu and you select "Widget in Editor". There is probably an example of a button or other onclick in there
If you don't know anything about AngularJS at all I would suggest you go out to Udemy and signup for one of there AngularJS classes. I learned a lot from the one I took.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 12:35 PM
Hi Drew,
I followed your instruction and have added a button, see below
As for the actual functionality, I added the function you provided earlier into the client script section of the widget form, yet when I click it nothing happens. Any ideas?