UI Action Button to Access Export > PDF Portrait

kshaw
Giga Guru

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.

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

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!

View solution in original post

18 REPLIES 18

Allen Andreas
Administrator
Administrator

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!

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

Excellent!!! Kept it simple 🙂

 

Hi,

Thanks!

I'm glad you found it helpful. 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!