- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 12:23 AM
Hi,
I have a field ('name') and a UI Macro on a form.
The UI Macro is just to get the field value and display it. The code is like below.
-----------------
<?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="jvar_user" object="true">
${ref_parent}.getValue("name");
</g:evaluate>
<div>name=${jvar_user}</div>
</j>
-----------------
Below is the page I'm getting. saying there is a reference error. I'm not familiar with Jelly and have no idea what's wrong. Can you help me out?
Solved! Go to Solution.
- Labels:
-
Studio
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 03:39 AM
Hi James,
below worked for me in my instance; you need to use <g2:evaluate> tag; phase 2 jelly tags
I believe using phase 1 jelly i.e. <g:evaluate> it doesn't get the value
<g2:evaluate var="jvar_user" object="true">
var value = current.name;
gs.info('Value is: ' + value);
value;
</g2:evaluate>
<div>name=$[jvar_user]</div>
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 01:13 AM
Hi James,
try adding logs
<g:evaluate var="jvar_user" object="true">
var value = current.name;
gs.info('Value is: ' + value);
value;
</g:evaluate>
<div>name=${jvar_user}</div>
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 02:02 AM
Hi,
I used ${jvar_user} but it still didn't work. And there's nothing in application logs.
Are you sure this works in your instance?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 03:39 AM
Hi James,
below worked for me in my instance; you need to use <g2:evaluate> tag; phase 2 jelly tags
I believe using phase 1 jelly i.e. <g:evaluate> it doesn't get the value
<g2:evaluate var="jvar_user" object="true">
var value = current.name;
gs.info('Value is: ' + value);
value;
</g2:evaluate>
<div>name=$[jvar_user]</div>
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 02:11 AM
Hi James,
Please refer to this link it might be useful for you
Mark helpful or correct if this helps.
Thanks
Swapnil

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2020 04:11 AM
Hi James,
Here is how your script should look like.
<?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="jvar_user" object="true">
var value = ${ref_parent}.name;
gs.log(""Value is "+value);
value;
</g:evaluate>
<div>name="${jvar_user}"</div>
</j:jelly>
If it still does not work, then go to system logs->All and check for this line
value is
Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.
Regards,
Asif
2020 ServiceNow Community MVP