- 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-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
01-21-2020 12:54 PM
Hi, I hope you can help me, I used your scritp and works great,but i'm trying to make a customised pdf whit some info not all, do you know if using the url I can change the view of the info, or do you know another way to make those, thanks for the help

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2021 09:42 AM
Excellent!!! Kept it simple 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2021 09:47 AM
Hi,
Thanks!
I'm glad you found it helpful. 🙂
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!