inmorphis-consu
Kilo Explorer

Well, Jelly is a tool for turning XML into executable code. It is a Java and XML based scripting and processing engine. ServiceNow uses Jelly to render web pages. ServiceNow actually has enhanced it to add even more capabilities.

So, Question arise, Why Jelly, why not just plain simple HTML?

Jelly produces HTML by interpreting a Jelly template (JT), which is itself an XML document. JT has their own set of XML tags and syntax, but they also directly incorporate the HTML tags that will be produced as output. These special tags do all the fancy stuff, including things that looks like more conventional programming language, the ability to use data from ServiceNow, ways to execute JavaScript.

jelly_f_improf_374x232.png

                                                                    Jelly high level

This is shown graphically at above. Whole process works like this, conceptually (don't worry about details at this moment):

  1. Request: A web browser sends a request to ServiceNow instance. URL is for a web page that will be rendered with Jelly (not all ServiceNow URLs result in using it, though most do).
  2. Jelly template selection: ServiceNow instance uses particulars in URL for request to select right JT to use for rendering that particular page.
  3. Jelly interpretation: Jelly engine is invoked with selected template, and template is processed to produce output HTML. There are manydetails about this process that we'll cover in later posts. For now, just note that engine can access data from ServiceNow instance, and use that data either as content in output, or to make decisions about what to output.
  4. Response: The output HTML is transmitted back to requesting web browser.

Write this to UI Page XML code:

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<g:evaluate>

var letters=["Hi","My","Jelly"];

</g:evaluate>

<j:forEach var="jvar_letters" items="${letters}">

<p>${jvar_letters}</p>

</j:forEach>

</j:jelly>

Hit "Try it" button and see output.

To read more such interesting posts. Click here