IT CanvassTalk to an advisor
Development · LessonBy , ServiceNow Trainer, 8 yrs · Published · current release · advanced

UI pages, macros & Jelly

The classic templating layer behind custom pages, formatters and legacy UI.

Quick answer

UI pages, UI macros and Jelly are ServiceNow's original server-side templating tools. Jelly is an XML syntax that mixes markup with logic and evaluates on the server to produce HTML. You still meet it in formatters, custom modals, and older customisations, so a working knowledge is essential even in a low-code era.

Key takeaways
  • The pieces
  • Two evaluation phases
  • When you still need it
  • Try it Yourself

The classic templating layer behind custom pages, formatters and legacy UI.

UI pages, UI macros and Jelly are ServiceNow's original server-side templating tools. Jelly is an XML syntax that mixes markup with logic and evaluates on the server to produce HTML. You still meet it in formatters, custom modals, and older customisations, so a working knowledge is essential even in a low-code era.

The pieces

  • UI page, a standalone page (HTML, a client script, and processing script).
  • UI macro, a reusable Jelly snippet embedded in forms, lists and pages.
  • Jelly, the <j:jelly> XML that runs the logic.

Two evaluation phases

<?xml version="1.0"?> <j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide"> <!-- Phase 1: server, use $[ ] --> <g:evaluate var="jvar_count"> var gr = new GlideAggregate('incident'); gr.addAggregate('COUNT'); gr.query(); gr.next(); gr.getAggregate('COUNT'); </g:evaluate> <div>Open incidents: ${jvar_count}</div> </j:jelly>
Phase 1 vs Phase 2. Jelly evaluates in two passes: $[ ] (phase 1, first) then ${ } (phase 2). Mixing them up is the number-one Jelly bug. When you can, prefer a modern widget or UI Builder instead of new Jelly.

When you still need it

Custom form formatters, some email layouts, and extending legacy UI16 pages still rely on UI macros. Learn to read Jelly; write new UI on the modern stack.

Practise this on your own free instance.
Set up your free instance →
Try it YourselfJavaScript
▸ Press Run to execute.

Runs in a sandbox in your browser. Mock gs and GlideRecord and sample data are provided.

Practice challenge

+0 XPStreak ×0
Question 1 of 3
Jelly is...
Practise this on your own free instance.
Set up your free instance →
Already working on ServiceNow and stuck on a live ticket?Get an expert ServiceNow developer on screen-share to finish your daily tasks with you. Deliver on time, protect your reputation and your job. Monthly support only, no task-wise plans.Task assigned · no idea where to startStill stuck · your job on the lineExpert joins your screenDelivered on timeExplore On Job Support