UI Action to Generate a Document Template (PDF)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 09:24 PM
Hello,
I have a Document Template (PDF) and I have it configured to a custom record type. I want to create a UI Action to fire off the Document Template and generate the custom PDF and attach it to the record. Is this possible?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 09:34 PM
Hi,
you might have to check the OOB implementation and enhance it based on your requirement
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 09:38 PM
Hey,
I have done this for generating work notes as pdf and attach to the record, you can modify the body as per your requirement and use the same logic to generate.
var html = '<p>' + current.work_notes.getJournalEntry(-1) + '</p>';
var result = new sn_pdfgeneratorutils.PDFGenerationAPI().convertToPDF(html,'incident', current.getUniqueValue(), 'My First PDF'); //(body,tablename,sys_id of record you want to attach','name of the 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-16-2022 09:48 PM
I thought about using HTML however I have a very specific Invoice Layout I need to follow from my financial division. I was hopping to leverage the Document Template PDF ability to take in a Form Fillable PDF and map it to my custom table. Have you used Document Tables in this regard before?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2022 09:54 PM
Got it,
Sharing one article that does the same:
Filling PDF forms in ServiceNow
Aman Kumar