How to access jvar variable defined in an <g:evaluate> tag from another <g:evaluate>?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2020 09:51 AM
Hi,
I have been trying to fetch the variable defined in one of the <g:evaluate> tags from another <g:evaluate> tag, all I receive is a null value, please see 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_sysID" expression="RP.getWindowProperties().get('sysID')" />
<g:evaluate jelly="true" var="jvar_tskPri">
gs.info('info '+${jvar_sysID}+' id '+jelly.jvar_sysID);
var tskPri = "";
var qt = new GlideRecord('task');
qt.addQuery('parent',jelly.jvar_sysID);
qt.query();
if(qt.next()){
tskPri = qt.priority;
gs.info('info '+tskPri);
}
queryPri;
</g:evaluate>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2020 10:58 AM
Hi,
Can you show the URL? i think the sydID param is the issue.
Is this right param in URL? or is it sys_id
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2020 12:02 PM
This script provided is defined in an UI page. I'm calling this UI page from an UI action where i'm setting the preference of the sysID. Below is the UI action script
function openPopup(){
var sysID = g_sysId;
var inv_id = g_form.getUniqueValue();
var window = new GlideDialogWindow('inv.task');
window.setTitle('Create Task');
window.setPreference('sysID',sysID);
window.setPreference('invId',inv_id);
window.setSize(400,300);
window.render();
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 09:47 AM
Hi,
In your UI page can you make this change as 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_sysID" expression="RP.getWindowProperties().get('sysID')" />
<g:evaluate jelly="true" var="jvar_tskPri">
gs.info('info '+jelly.jvar_sysID);
var tskPri = "";
var qt = new GlideRecord('task');
qt.addQuery('parent',jelly.jvar_sysID);
qt.query();
if(qt.next()){
tskPri = qt.priority;
gs.info('info '+tskPri);
}
queryPri;
</g:evaluate>
Now check the log what you get.
Thanks,
Ashutosh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2020 10:03 AM
Hi Srikanth,
if the sysID is of parent task then no need to use 2 g:evaluate tags
<?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 jelly="true" var="jvar_tskPri">
var tskPri = "";
var qt = new GlideRecord('task');
qt.addQuery('parent',RP.getWindowProperties().get('sysID'));
qt.query();
if(qt.next()){
tskPri = qt.priority;
gs.info('info '+tskPri);
}
queryPri;
</g:evaluate>
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