UI MACRO, How to iterate array of object from Jelly Variable?????
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2018 10:10 AM
COde 1:- Below code is using for create an array of object.
<g2:evaluate var='jvar_obj1' jelly="true" object="true">
var sComments = new Array();
var gr2 = new GlideRecord('u_triangular_tasting_score');
gr2.addQuery('u_sample_id',current.getValue('u_tri_session_id'));
gr2.addQuery('u_panelist',gs.getUserID());
gr2.addQuery('u_sample',current.getValue('u_sample_label'));
gr2.query();
if(gr2.next())
{
var ids = gr2.u_sample_a_comments.split(',');
var comments = gr2.u_sample_a_comments.getDisplayValue().split(',');
for(var i=0; i<comments.length; i++)
{
sComments[i] = new Object();
sComments[i] = {sys_id: ids[i], value: comments[i]};
}
}
sComments;
</g2:evaluate>
// comment:- below code is used to invoke a macro and pass array as an input.
<g:macro_invoke macro="ub1_slushbucket" obj1="$[jvar_obj1]" />
Code 2 :- read input array( $[jvar_obj1] ) and print in slushbucket select option View.
//comment:- Below code works fine and print length of the array( which is 6).
<label for="${jvar_name}_left">$[jvar_obj1.length] </label>
//commnets:- Below code is used to iterate the array which is not working as expected.
<select id="${jvar_name}_right"
name="${jvar_name}_right" class="slushselect form-control"
multiple="yes" size="5" width="60"
onkeydown="${jvar_name}.onKeyMoveRightToLeft(event);"
ondblclick="${jvar_name}.moveRightToLeft();">
<options><j:forEach var="jvar_status" items="${jvar_obj1}">
<option value="${jvar_status.sys_id}">${jvar_status.value}</option>
</j:forEach>
</options>
</select>
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2018 09:01 PM
You can even watch first three episodes of Technow for further details on jelly scripting hosted by chuck tomasi and andrew kincaid
Hope that helps
Thanks,
Siva