Query in g:evaluate is not working.

Rohant Joshi2
Kilo Expert

Hi All,

 

I am stuck at a point to complete my task, please guide me on this.

 

I am trying to display all those incidents in a UI Page whose creation date is less than or equal to date selected in my new customized field 'incident_date' on my current incident.

 

For this I have created a UI action on my incident form which is calling the UI Page. For the sake of test to my approach I tried pulling data with query of all the active=true incident and it working fine.

But when I add query for date comparison it is showing me error and the reason is not known to me.

I am adding the code which is giving me error.

 

 

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

<style>

 

th, td {

      padding: 5px;

}

</style>

 

<j:set var="jvar_incidet_date" value = "${sysparm_incident_date}" />

 

<g:evaluate var="jvar_incident" object="true">

var gr = new GlideRecord('u_my_incidents');

gr.addQuery('active', 'true');

gr.addQuery('created_on','<=','${jvar_incidet_date}');       --->   error

gr.query();

gr;

</g:evaluate>

1 ACCEPTED SOLUTION

Completely forgot you need to escape the <= in xml. Try this line instead and make sure that your jelly.jvar_incident_date is not in quotes.


gr.addQuery('sys_created_on', '&lt;=', jelly.jvar_incident_date);



Also, you need to make sure to include the jelly attribute:


<g:evaluate var="jvar_incident" object="true" jelly="true">


View solution in original post

10 REPLIES 10

Rahul183
Tera Contributor

Same issue happen with me 

Brad can you please help to get the variable value in add query 

I am passing the value to add query but its not working for me

<?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' jelly="true">
          var val = current.getValue('sys_id');
          val;
</g2:evaluate>
   
<h1>$[jvar_sys_id]</h1>
<g:evaluate jelly="true" var="jvar_gr" object="true" >    

var gr=new GlideRecord("u_uc4_lrp_concurrent_program");

var parent_no=current.sys_id;
gr.addQuery('parent',jelly.jvar_sys_id);
gr.orderByDesc('sys_created_on');
gr.addQuery('u_type','task');
gr.query();
gr;

</g:evaluate>