- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2019 12:47 PM
In effort to give better/simpler user experience to our non-technical agents, I want to create a UI Action Button "Export to PDF" that has the same functionality as the contextual menu item Export > PDF (Portrait).
However, in doing much searching on similar topics I have found no working solution and most responses are somewhat dated. The most recent reply that seemed to provide a solution just did not work in London on our instance.
It would seem a pretty simple thing to have an action that access the same function as the menu item.
Hoping for help in finding a working solution.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-25-2019 01:42 PM
Hi,
This can be achieved by creating a UI Action with the following settings:
Client: Checked
OnClick set to: exportPDF()
Show Update: Checked
Form Button: Checked
and script to this:
function exportPDF() {
var sysparm_table = g_form.getTableName();
var sysparm_sys_id = g_form.getUniqueValue().toString();
var instanceName='https://instance_name.service-now.com/';
var url = instanceName+sysparm_table + '.do?PDF&sys_id=' + sysparm_sys_id;
g_navigation.openPopup(url);
}
Change out instance_name in URL to your instance's subdomain.
Works on Madrid as I just did this.
Please mark reply as Helpful/Correct. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2019 02:08 PM
Thank you for reply. It worked but I wanted to have instance name dynamic instead of hard coded so modified to this...
function exportPDF() {
var sysparm_table = g_form.getTableName();
var sysparm_sys_id = g_form.getUniqueValue().toString();
// var instanceURL = 'https://ucscdev.service-now.com/';
var instanceURL = "https://" + location.hostname + "/";
var url = instanceURL + sysparm_table + '.do?PDF&sys_id=' + sysparm_sys_id;
g_navigation.openPopup(url);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-29-2019 03:11 PM
Sounds great. You did not state that in your original post else I would have helped with that too. Otherwise, using exactly what I created works fine.
Have a great day.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2020 01:01 AM
Hi Allen A,
I was wondering. Is there any way to modify your script so the resulting pdf file name is not the table name but rather the value of the "number" field?
So my pdf file name would be INC1234.pdf and not just incident.pdf.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2020 05:37 AM
Hi,
Can definitely understand your need for this, unfortunately, from all that I've heard of and seen on the forums, this isn't possible. You aren't able to rename the PDF. You may want to consider creating your own post to track that conversation separately, but anything that I've seen still, doesn't allow for default renaming.
Sorry!
Please mark reply as Helpful, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-27-2020 06:04 AM
Thanks for the quick response. I couldn't find any method either in my research. So, I've added the request to the Idea Portal to see if others would like this feature. Perhaps ServiceNow can provide such a feature in a future release if enought companies request it.