Gliderecord query in <g:evaluate> overwriting and displaying the previous object values by the last one in while "jelly script" (<j:while test="\${jvar_Visible.next()}">),though loop is running correctly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2016 03:52 AM
I have designed a ServiceNow UI Page where I have used Glide Query in <g:evaluate> tag mentioned below -
<g2:evaluate var='jvar_Visible' object='true'>
var FirChild = new GlideRecord('u_requested_action_details');
FirChild.addQuery('u_request_detail',sourceiID);
FirChild.query();
gs.log('soumalya'+FirChild);
FirChild;
</g2:evaluate>
and then run a while loop jelly script under it -
<j:while test="${jvar_Visible.next()}">
<g:ui_table>
<g:ui_header>Child Preview</g:ui_header>
<table>
<th>Position Classification</th>
<tr>
<td >
<label>$[FirChild.u_po_country.getDisplayValue()]</label>
</td>
<td colspan="2">
<label>$[FirChild.u_po_city.getDisplayValue()]</label>
</td>
</tr>
<tr>
<g:ui_table>
Now suppose if the while is running for 2 times
it is creating the two Child Preview section marked in Red,but displaying the last child (in this case second child) information for both the child values.
If the loop is running for 3 times,it will create 3 child sections.but all are displaying last child(3rd in this case) information.Details coding and screenshot attached.
So is it overwriting the previous child information with the ;latest one,or what is happening here?
and how can I resolve it?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2016 08:57 AM
Hi,
The problem with your code is phase mismatch. You are using glide tag in phase 2 and jelly in phase 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2016 06:52 AM
Thanks abhinay.
It helps after using phase 2.
But now I need another clarification -
I have to use if query here,because I want to show particular message depending on another field value.
Here is the sample query I have written which is not working -
<g2:evaluate var='jvar_Visible' object='true'>
var FirChild = new GlideRecord('u_requested_action_details');
FirChild.addQuery('u_request_detail',sourceiID);
FirChild.query();
gs.log('soumalya'+FirChild);
FirChild;
</g2:evaluate>
<j2:while test="${jvar_Visible.next()}">
<g:ui_table>
<g:ui_header>Child Preview</g:ui_header>
<table>
<th>Position Classification</th>
<tr>
<td >
<label>$[FirChild.u_po_country.getDisplayValue()]</label>
</td>
<td colspan="2">
<label>$[FirChild.u_po_city.getDisplayValue()]</label>
</td>
</tr>
<j2:if test="${$[FirChild.u_po_city.getDisplayValue()] == 'DETO'}"> // if value from the above field is "DETO" print the following message.
We did not find any active incidents.
</j2:if>
</table>
</g:ui_table>
</j2:while>
Do I have to remove additional $ sign from the if tag (in Red)? or how can I use this in while loop ?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2016 02:33 PM
You need to use [ ] in phase2 not curly brackets. Here you go, this should work. Don't forget to mark my response as correct
<g2:evaluate var='jvar_Visible' object='true'>
var FirChild = new GlideRecord('u_requested_action_details');
FirChild.addQuery('u_request_detail',sourceiID);
FirChild.query();
gs.log('soumalya'+FirChild);
FirChild;
</g2:evaluate>
<j2:while test="$[jvar_Visible.next()]">
<g:ui_table>
<g:ui_header>Child Preview</g:ui_header>
<table>
<th>Position Classification</th>
<tr>
<td >
<label>$[FirChild.u_po_country.getDisplayValue()]</label>
</td>
<td colspan="2">
<label>$[FirChild.u_po_city.getDisplayValue()]</label>
</td>
</tr>
<j2:if test="$[FirChild.u_po_city.getDisplayValue()== 'DETO']"> <!-- // if value from the above field is "DETO" print the following message.-->
We did not find any active incidents.
</j2:if>
</table>
</g:ui_table>
</j2:while>