Is there a server-side script mechanism to run generate HTML from a Template (Jelly or other) ?

David Hubbard
Tera Guru

I am looking at how we might create templated output as a PDF report in our Scoped Application.

 

I can see that I can use the PDFGenerationAPI - however this requires HTML input.

 

So I was wondering if it was possible to use a Server-side templating engine (possibly Jelly-based?) to allow production of the HTML from template with boiler plate HTML and embedded scripting.  

 

As far as I can see the normal usage of Jelly is in UI Pages, which are used for web request handling (HTML straight back to browser) and may not be accessible from a scripting usage.  But is there an equivalent?

 

I'm going to take a look at using standard Template Strings (ECMAScript 2021) [like this] but wondering if there is a better alternative.

 

5 REPLIES 5

ncp
Mega Guru

This might be a late response but take a look at this and see if it meets your needs.

1. Create a HTML document template (assuming that you have that plugin - unsure about licensing)

2. Use the script below

var recordId = <sysidof the record you want to generate pdf from>
var documentTemplateId = <sysid of the document template>
var pdfName = <name of the pdf file>
new sn_doc.GenerateDocumentAPI().generateDocumentForTask(recordId, documentTemplateId, pdfName);