Jelly script for while loop

IamAmolB
Tera Guru

Hi Experts,

Do we have any idea about how can we add while or for loop in jelly script to render following elements

<tr>

<td nowrap="true">

<g:ui_reference name="assignment_group0" id="assignment_group0" table="u_rc_assignment_group_mapping" value="" onchange="checkAsignee(0)"/>

</td>

<td nowrap="true">

      <select id="assign_to0" name="assign_to0">

<option value="">---Select---</option>

</select>

</td>

      <td nowrap="true">

  <input name="notes0" id="notes0" value=" " />

</td>

</tr>

Regards,

Amol Bavaskar

1 ACCEPTED SOLUTION

divya mishra
Tera Guru

Hey Amol,



Could you please try the below code :



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


// glide record here


}


</g:evaluate>



then in the section you have the drop down put the below code


<td>


<select name ="xyz" id="xyz" >


<j:while test="${jvar_list.next()}">


<option value="${jvar_list.getValue('fieldName')}">${jvar_list.getValue('fieldName')}</option>


</j:while></select>


</td>



Please Hit ✅Correct, ��Helpful, or ��Like depending on the impact of the response


Have a lovely day ahead




Regards,


Divya Mishra


View solution in original post

3 REPLIES 3

divya mishra
Tera Guru

Hey Amol,



Could you please try the below code :



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


// glide record here


}


</g:evaluate>



then in the section you have the drop down put the below code


<td>


<select name ="xyz" id="xyz" >


<j:while test="${jvar_list.next()}">


<option value="${jvar_list.getValue('fieldName')}">${jvar_list.getValue('fieldName')}</option>


</j:while></select>


</td>



Please Hit ✅Correct, ��Helpful, or ��Like depending on the impact of the response


Have a lovely day ahead




Regards,


Divya Mishra


Patrick Schulte
Kilo Guru

Besides <j:while> there is also a <j:forEach> to iterate over array-like objects.


Example usage:


<g:evaluate>


var fields = ['caller_id', 'name', 'whatever'];


</g:evaluate>



<j:forEach items="${fields}" var="jvar_field_name">



<g:evaluate jelly="true">


field_name = jelly.jvar_field_name;


</g:evaluate>



${field_name}



</j:forEach>