- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2019 06:22 AM
Hi All,
I have one requirement where I need to push some elements to an array and that array will be sent to the Option value of the dropdown list. I am able to form the array but stuck at pushing that array to the dropdown list option in the UI page. If someone has implemented this in an UI page, please post your suggestions.
Thank You.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2019 11:22 PM
You have to store them in array and then using for loop you will set it..
here is the sample code which i tried on my instance. just make the changes based on your need.
<?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:evaluate var="jvar_ur" object="true">
var gr = new GlideRecord('incident');
gr.addQuery('sys_id','d41f0e10db29b300e4d95740cf9619fa'); //sys_id of an user
gr.query();
var userList =[];
if(gr.next()){
var gr2 = new GlideRecord('sys_user');
gr2.addQuery('sys_id',gr.caller_id);
//gr2.addQuery('u_site',gr.u_site);
gr2.query();
while(gr2.next()){
userList.push(gr2.department.id);
}
}
userList;
</g:evaluate>
<select id="ur">
<option value="">-- None --</option>
<j:forEach items="${jvar_ur}" var="jvar_array_item">
<option value="${jvar_array_item}">${jvar_array_item}</option>
</j:forEach>
</select>
</j:jelly>

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2019 06:28 AM
seems like same question have been asked on below thread. may i know where exactly have you stuck ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2019 06:46 AM
Hi Harshvardhan,
I am stuck at pushing an array to the dropdown list. PFB code for your reference.
<g:evaluate var="jvar_grec" object="true">
var gr1 = new GlideRecord('Table1');
gr1.addQuery('u_userid', gs.getUserID());
gr1.query();
gr1;
var jobcodelist =[];
var userList =[];
while(gr1.next()){
jobcodelist.push(gr1.u_jobcode.toString());
var gr2 = new GlideRecord('Table1');
gr2.addQuery('u_jobcode',jobcodelist); //Multiple jobcode check
gr2.addQuery('u_site',gr1.u_site);
gr2.query();
gr2;
while(gr2.next()){
if(userList.toString().indexOf(gr2.u_userid.name)==-1){ //To remove duplicate values from the array
userList.push(gr2.u_userid.name); //This array will be pushed to the dropdown list
}
}
}
userList;
</g:evaluate>
<table style="border: 1px solid #e6e3e3;background-color: #e6e3e3 ; width:100%;" cellpadding="20">
<tr>
<td style="padding-top:50px;padding-left: 70px"></td>
<tr></tr>
</tr>
<tr>
<td style="padding-top:0px;padding-left:30px;padding-bottom:20px">
<select style="width:200px;background-color: #efefef" id="DropDown">
<option value="">--Please Select--</option>
<j:while test="${jvar_grec.next()}">
<j2:forEach var="jvar_item" items="${jvar_grec}">
<option value="${jvar_item}">${jvar_item}</option>
</j2:forEach>
</j:while>
<input type="hidden" id="user_sys_id" value="${gr2.u_userid}" />
</select>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2019 11:01 PM
Hi Harshavardhan,
Please let me know if this piece of code is correct to push the array "userList" to the dropdown option value.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2019 11:22 PM
You have to store them in array and then using for loop you will set it..
here is the sample code which i tried on my instance. just make the changes based on your need.
<?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:evaluate var="jvar_ur" object="true">
var gr = new GlideRecord('incident');
gr.addQuery('sys_id','d41f0e10db29b300e4d95740cf9619fa'); //sys_id of an user
gr.query();
var userList =[];
if(gr.next()){
var gr2 = new GlideRecord('sys_user');
gr2.addQuery('sys_id',gr.caller_id);
//gr2.addQuery('u_site',gr.u_site);
gr2.query();
while(gr2.next()){
userList.push(gr2.department.id);
}
}
userList;
</g:evaluate>
<select id="ur">
<option value="">-- None --</option>
<j:forEach items="${jvar_ur}" var="jvar_array_item">
<option value="${jvar_array_item}">${jvar_array_item}</option>
</j:forEach>
</select>
</j:jelly>