- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2015 11:13 PM
Hi All,
I have used "GlideRecord" for my custom table which is highlighted below. I'm using the same "GlideRecord variable" for number of times as highlighted in my code. I'm able to fetch the data's under first while loop only but I want it to work in other while loops too.
I added all tables under different div and also under <g2> tag and also tried under single div and <g2> tag, but I'm not getting data's. Can any one suggest me the possible ways to resolve this issue.
<?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:ui_form id="training_plans" name="training_plans">
<html>
<style>
My style goes here..........
</style>
<body>
<br/>
<table style="float: right">
<tr>
<td><a href="u_training_plan.do" class="button"><b>Register Trainings</b></a>
</td>
</tr>
</table>
<br/>
<!-- Below is the GlideRecord-->
<g:evaluate object="true">
var trainings = new GlideRecord('u_training_plan');
trainings.query();
</g:evaluate>
<div>
<table class="a2_table">
<tr>
<th colspan="5" class="a2_th"><h4><b>Trainings Recommended</b></h4></th>
</tr>
<tr>
<th class="a2_th"><b>Name </b> </th>
<th class="a2_th"> <b>Trainings </b></th>
<th class="a2_th"><b> Status </b> </th>
</tr>
<j:while test="${trainings.next()}">
<j:if test="${trainings.u_status == 'Recommended'}">
<tr>
<td class="a2_td">${trainings.u_name.getDisplayValue()} </td>
<td class="a2_td">${trainings.u_trainings.getDisplayValue()} </td>
<td class="a2_td">${trainings.u_status} </td>
</tr>
</j:if>
</j:while>
</table>
<br/>
<table class="a2_table">
<tr>
<th colspan="5" class="a2_th"><h4><b>Trainings Planned</b></h4></th>
</tr>
<tr>
<th class="a2_th"><b>Name </b> </th>
<th class="a2_th"> <b>Trainings </b></th>
<th class="a2_th"><b> Status </b> </th>
</tr>
<j:while test="${trainings.next()}">
<j:if test="${trainings.u_status == 'Enrolled'}">
<tr>
<td class="a2_td">${trainings.u_name.getDisplayValue()} </td>
<td class="a2_td">${trainings.u_trainings.getDisplayValue()} </td>
<td class="a2_td">${trainings.u_status} </td>
</tr>
</j:if>
</j:while>
</table>
<br/>
<table class="a2_table">
<tr>
<th colspan="5" class="a2_th"><h4><b>Trainings Completed</b></h4></th>
</tr>
<tr>
<th class="a2_th"><b>Name </b> </th>
<th class="a2_th"> <b>Trainings </b></th>
<th class="a2_th"><b> Status </b> </th>
</tr>
<j:while test="${trainings.next()}">
<j:if test="${trainings.u_status == 'Completed'}">
<tr>
<td class="a2_td">${trainings.u_name.getDisplayValue()} </td>
<td class="a2_td">${trainings.u_trainings.getDisplayValue()} </td>
<td class="a2_td">${trainings.u_status} </td>
</tr>
</j:if>
</j:while>
</table>
</div>
</body>
</html>
</g:ui_form>
</j:jelly>
Thanks,
Sowmya
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2015 11:19 PM
Try this -- after the first and second of your "</j:while>" tags, do the following:
<g:evaluate>
trainings.setLocation(-1);
</g:evaluate>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2015 11:19 PM
Try this -- after the first and second of your "</j:while>" tags, do the following:
<g:evaluate>
trainings.setLocation(-1);
</g:evaluate>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2015 11:46 PM
Hi valor,
Thank you, It's working.
Can you please explain me why can't we use "GlideRecord variable" which holds the value under multiple loops?
Thanks,
Sowmya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2015 02:11 PM
The the GlideRecord object is really an API to interact with the database. So when you call "trainings.next()" you're looping through the DB result set, and when it gets to the end, it returns "false" -- no more records left.
If it reset automatically back to the first in the list, your while loop would never complete.
Essentially, the your GlideRecord variable DOES hold the value under multiple loops; it's just that you have to reset to the position every time -- just like you would in a traditional "for" loop using different iterators.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2015 11:35 PM
Hi Valor,
Thanks for the information
Thanks,
Sowmya