Add "Download All Attachments" button on ticket form in Service Portal

Chris17
Tera Contributor

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

find_real_file.png

I know where to make these edits, but as to how I am unsure and inexperienced within the Service Portal. Any ideas?

1 ACCEPTED SOLUTION

DrewW
Mega Sage
Mega Sage

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.

View solution in original post

10 REPLIES 10

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.

 

Chris17
Tera Contributor

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. 

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

 

Mannie1
Tera Contributor

Hey Chris,

 

Were you able to figure this out? I actual have the same request from my end users.

 

Thanks,

Mannie

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you will have to customize that widget.

If that is OOB widget; then you need to clone that and customize it

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader