How to access jvar variable defined in an <g:evaluate> tag from another <g:evaluate>?

srikanthvk
Giga Expert

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>

4 REPLIES 4

Ashutosh Munot1
Kilo Patron
Kilo Patron

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

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();
}

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

Ankur Bawiskar
Tera Patron
Tera Patron

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

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader