- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 12:07 PM
Hi There,
Happy new year to you !!
In this new year, I am exploring few new things and got stuck at one place not sure if it can be achieved or not. Performs some alternative can be there.
All I want to do is access the current object in the UI macro when its added to the field so that I can set the sys_id in one of the variable using below syntax and use it in few of the if conditions to render HTML.
<g:set var="jvar_sys_id" value="${current.sys_id}"/>
But unfortunately, its not working and showing value as NULL.
Could you please suggest some alternate solution for same?
Notes:
1. I am aware that we can use the sys_id in the script tags, but as per another community post I can't render script data back to the UI macro jelly scripts, as it renders first.
2. I know about the ${ref} which returns only the reference of table and field on which UI macro is called but not the sys_id or any unique identifier for the record.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 02:29 PM
It's been a while, but, I believe you can only reference current when using "phase 2" so g2.
Below is a really simple example - you can add this as a formatter to any form view and it will show the sys_id of the current record.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate var='jvar_sys_id'>
var val = current.getValue('sys_id');
val;
</g2:evaluate>
<p>sys_id= $[jvar_sys_id]</p>
</j:jelly>
Michael D. Jones
Proud member of the GlideFast Consulting Team!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 02:29 PM
It's been a while, but, I believe you can only reference current when using "phase 2" so g2.
Below is a really simple example - you can add this as a formatter to any form view and it will show the sys_id of the current record.
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g2:evaluate var='jvar_sys_id'>
var val = current.getValue('sys_id');
val;
</g2:evaluate>
<p>sys_id= $[jvar_sys_id]</p>
</j:jelly>
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 09:49 AM
@Michael Jones - Thank you very much for this solution. I was going through a lot of articles since last week, but didn't get anything. After changing to phase 2 ( g2) it worked like a charm. Thank you very much.
If possible, could you please share the detailed jelly scripting handbook for ServiceNow or any course for learning.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2024 12:00 PM
I'll admit that most of what I learned was through trial, error, and picking apart a lot of the UI pages that come out of the box. Most of it is just javascript and html. I do recall some great videos that Chuck Tomasi had put out there that helped me get started:
There are 3 of vids - this is a link to the first one (which has links to the other two) - they are a bit old, but the technology (Jelly) hasn't changed so --- still applicable!
https://www.servicenow.com/community/developer-blog/technow-ep-1-servicenow-jelly-scripting-part-1-o...
I use these as references for the (more and more rare) instances where I need to brush up (well, that is to say I search for these on Docs as the current version changes, but something like these have been around for sometime).
https://docs.servicenow.com/bundle/vancouver-application-development/page/script/general-scripting/r...
https://docs.servicenow.com/bundle/vancouver-application-development/page/script/general-scripting/c...
Michael D. Jones
Proud member of the GlideFast Consulting Team!