- 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
‎08-01-2022 10:15 AM
Hi Allen,
Do you know how I could modify your script to only export a few specific fields on the form, instead of the whole form?
Thanks in advance for any help,
Carlos
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2022 02:58 AM
Hi Allen,
First of all, thank you for this simply great solution!
I want to know if I don't want some fields on pdf, then what do I need to do?
Are there any scripts to avoid some specific fields, suppose from the incident table?
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2023 01:10 PM
Hi Allen,
Can we do it for Powerpoint as well ? if yes, please let me know
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2024 10:49 AM
It's working smoothly - Washignton DC =D
The solution provided by @Allenovation requires the user from Employee Center read roles for the different types of records.
To develop something more suitable I'm using this Home - Documentation (rawgit.com) .
^^

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2024 11:06 AM
Hi,
Thanks for confirming it's still good to go on the Washington version. As far as what I provided requiring any special roles, it only requires whatever is needed by the platform for the user to access the data, regardless of Employee Center. The user can't just print a PDF for data they don't have access to and my script doesn't cause any excess dependency than what is already required on their instance.
As far as using a 3rd party library to accomplish your requirement, that's neat to hear! 😀
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!