- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2018 12:57 PM
Hi all,
I am pretty new to SN. Here is what I wanted to do:
I want to create a button "print" that will launch the printing of the record.
I have already created the UI action.
My question is the following:
Where do I add the "window.print()" command? is it inside the UI action script or inside the UI page.
A specific answer with an example would be greatly appreciated!
Please do not refer me to SN documentation on UI actions or Pages, I already covered that!
ps. I want to implement the solution as stated above, not with the export to pdf or other options.
Thanks for your help
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2018 01:13 PM
Hi,
you have to use the window.print() command in the UI Page, below an example:
<input name="btnGo" id="btnGo" type="button" value="Print" onclick="window.print()"></input>
Hope this will fit your need.
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
Thanks you
Cheers
Alberto

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2018 01:13 PM
Hi,
you have to use the window.print() command in the UI Page, below an example:
<input name="btnGo" id="btnGo" type="button" value="Print" onclick="window.print()"></input>
Hope this will fit your need.
If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.
Thanks you
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2018 01:29 PM
Hi Alberto,
Thank you for your answer. It works indeed, although there's a catch: When I click on the print icon, the print preview shows the dialog window (to print the record). This user had the same issue:
https://community.servicenow.com/community?id=community_question&sys_id=74050f2ddbd8dbc01dcaf3231f9619e3
Do you know of a better way to remove the dialog window?
I added a window..close() right after "window.open()" as suggested in the thread. It's not working.
Thanks again

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2018 01:39 PM
Try with this function:
GlideDialogWindow.get().destroy();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2018 01:45 PM
I already tried it in the client script section: the result is that the dialog window pops up and disappears immediately.
Should I call it inside another function maybe?