- 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 01:13 PM
Did you define the function getCurrentPageURL? I gave you something that was from the Platform UI as a strait copy. Its not just going to work on Service Portal. Service Portal has different ways to do some things. So you are going to have to update the function.
Also you cannot just paste that function into the client script of your widget. Thats not going to work out. AngularJS uses an object that has user methods, so you have to add your function to the $scope or "c" object as a method. There are lots of examples of this in many of the widgets.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 01:32 PM
Apologies, I misunderstood. When you said, "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." i took it as being a much easier lift than it's turning out to be.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2022 08:53 AM
It is easy once you know the URL to use if you know AngularJS.
You may need to use the $location service to get some of the info
https://docs.angularjs.org/api/ng/service/$location
And also the $window service probably
https://docs.angularjs.org/api/ng/service/$window
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-30-2022 11:02 AM
Hey Chris,
Were you able to figure this out? I actual have the same request from my end users.
Thanks,
Mannie
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2022 08:23 AM
Hi,
you will have to customize that widget.
If that is OOB widget; then you need to clone that and customize it
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader