- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-22-2022 11:47 PM
Hi everyone,
I'm trying to create a UI Action to download/print emails as PDF. I have followed this suggestion but for emails is not usefull (html is not translated):
Thoughts?
Thanks in advance.
Dennis.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 12:34 AM
Hey,
You can create the UI action on the table and fetch html body and details.
One thing, you can't auto-download the file, but it will be added as attachment, I had done this for work notes.
Below code you can use:
var html = '<p>' + current.work_notes.getJournalEntry(-1) + '</p>';// you can fetch html body to pass on to the pdf
var result = new sn_pdfgeneratorutils.PDFGenerationAPI().convertToPDF(html,'incident', current.getUniqueValue(), 'My First PDF');//body of pdf, table where you want to add the pdf, sys_id of the record where you want to add the generated pdf, name of file
;
action.setRedirect(current);
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 12:24 AM
HI Dennis,
Check this thread, this might give you an idea: https://community.servicenow.com/community?id=community_question&sys_id=acf751c2dbe893887b337a9e0f96...
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 12:34 AM
Hey,
You can create the UI action on the table and fetch html body and details.
One thing, you can't auto-download the file, but it will be added as attachment, I had done this for work notes.
Below code you can use:
var html = '<p>' + current.work_notes.getJournalEntry(-1) + '</p>';// you can fetch html body to pass on to the pdf
var result = new sn_pdfgeneratorutils.PDFGenerationAPI().convertToPDF(html,'incident', current.getUniqueValue(), 'My First PDF');//body of pdf, table where you want to add the pdf, sys_id of the record where you want to add the generated pdf, name of file
;
action.setRedirect(current);
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 01:25 AM
Hi Aman,
Thanks a lot! But I would like to obtain something like 'preview email'... do you know if it's possible?
This is the email format:
And this is how it looks like with your suggestion:
Could we do the same but with preview email? This is the preview code (OOTB):
Thanks.
Dennis

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2022 02:31 AM
Can you use getHTMLValue() instead of getValue in the UI action code
So that your html tags are intact and show email in correct format
Aman Kumar