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

merry678gar
Tera Contributor

Hello,


In a ServiceNow Scoped Application, creating templated PDF output involves generating HTML content that can be passed to the PDFGenerationAPI. While your ideas around server-side templating (e.g., Jelly-based solutions or ECMAScript template strings) are viable, let’s examine practical approaches to achieve this:

1. Jelly-Based Templates
Jelly Limitations: Jelly templates are primarily designed for use in UI Pages and are typically tied to user-interface rendering. While you could theoretically use Jelly to generate server-side HTML, it’s not natively designed for scripting usage outside of its UI context.
Custom Implementations: If you want to use Jelly, you could define Jelly templates as part of the application’s metadata (e.g., stored in Script Includes or as static resources) and invoke them in a controlled manner using Jelly scripting. However, this might involve a lot of overhead, including parsing and managing the output yourself.
Best Regards
merry867

Hi

 

Thanks - yes, I think Jelly may be a bit clunky for this.

 

I guess I am trying to tease out whether these was an alternative feature - similar approach to Jelly (with html template and embedded script handling for data) in SN that I have missed.  

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@David Hubbard 

I don't think so there is an option here.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

merry678gar
Tera Contributor

Hello,
I hope that u find good answer that i suggested.
unitedhealthcare login
Best Regards
merry678