Download/Print email to PDF

Dennis2
Kilo Expert

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):

find_real_file.png

Thoughts?

Thanks in advance.

Dennis.

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

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 🙂

View solution in original post

7 REPLIES 7

Not applicable

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

Aman Kumar S
Kilo Patron

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 🙂

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:

find_real_file.png

And this is how it looks like with your suggestion:

find_real_file.png

 

Could we do the same but with preview email? This is the preview code (OOTB):

find_real_file.png

Thanks.

Dennis

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