Adding a Close Button to a Form

jateater
Kilo Explorer

I want to add a close button to my form.   In case the user is populating the form and figures out, they really don't need to.   I just want it to just exit the form and take them back to the list of records.

 

So I created a UI Action and put the following script it.

 

action.setRedirectURL(current);

 

It is not working correctly.  

 

On the same note, is it possible to create a UI Action that will Export to PDF?  

Instead of the user having to right clicking the header > Export > PDF.   It would be much nicer if they can just click a button.

 

Thanks in advance for any guidance.

1 ACCEPTED SOLUTION

amadosierra
Kilo Guru

Include in your UI Action a call to setAbortAction and use setRedirectURL to the list you want.



current.setAbortAction();


action.setRedirectURL("incident_list.do");



Using setRedirectURL this way will force the user to go back to the list you want, whereas setRedirectURL(previous) will send them back to whatever form/list they were. It depends on what you're trying to achieve.



As for the Export to PDF button. Try creating a UI Action as follows:



Name: Save as PDF


Active: True


Show insert: false


Show update: true


Form button: true


Script:


action.setRedirectURL('incident.do?PDF&sys_id=' + current.sys_id + '&sysparm_view=ess');


View solution in original post

4 REPLIES 4

Subhajit1
Giga Guru

Hi James,


I think probably you might need to use action.setRedirectURL(previous);


On clicking the UI Action, the User will be Navigated to the Page from where he came to the Current Page.



For the 2nd Part of your requirement, you can take a look at the Develop Community as there you might find your answer.



Thanks,


Subhajit


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi James,



You may find the below thread as helpful


Export to PDF UI Action


Custom PDF Files in ServiceNow through PDFCrowd-John James Andersen



Thanks,


Pradeep Sharma


amadosierra
Kilo Guru

Include in your UI Action a call to setAbortAction and use setRedirectURL to the list you want.



current.setAbortAction();


action.setRedirectURL("incident_list.do");



Using setRedirectURL this way will force the user to go back to the list you want, whereas setRedirectURL(previous) will send them back to whatever form/list they were. It depends on what you're trying to achieve.



As for the Export to PDF button. Try creating a UI Action as follows:



Name: Save as PDF


Active: True


Show insert: false


Show update: true


Form button: true


Script:


action.setRedirectURL('incident.do?PDF&sys_id=' + current.sys_id + '&sysparm_view=ess');


Hi Amado



I have been trying the same thing on my custom application and have gotten further after your answer, however, I am trying to export and replaced the 'incident.do' with my table name. I get the option to open and save the pdf, however, it does not take out any data from my form.



action.setRedirectURL('x_pfgb3_dev_a_te_p_dev_a_te_production_issue_table?PDF&sys_id=' + current.sys_id + '&sysparm_view=ess');



If I use the 'incident.do' it will export the incident form.



Thank you in advance for taking a look