- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2021 11:38 PM
Dear all,
<section>
<g:evaluate jelly="true" object="true" var="jvar_arr">
var arr = gs.getProperty(instances').split(','); // give the property name here
arr;
</g:evaluate>
<div class="input-block input-col">
<div class="field-label1"> <span class="asterisk">*</span> <span> instances </span> </div>
<div class="field-input multiselect-item">
<input type="text" id="Instances" placeholder="Start typing here to see results.." readonly="true" required="true" onclick="openSelectableDropdown('#Instances_drop_down', '#Instances_drop_down_arrow')"
selectedValue="" />
<i id="Instances_drop_down_arrow" class="fas fa-angle-down dropdown-arrow" onclick="toggleSelectableDropdown('#Instances_drop_down', '#Instances_drop_down_arrow')"></i>
<div id="Instances_drop_down" class="autocomplete-dropdown selectable-dropdown">
<div class="dropdown-wrapper">
<j:forEach items="${jvar_arr}" var="jvar_element">
<div class="dropdown-item" onclick="selectMulti(this, '#Instances',
'#Instances_drop_down');" value="${jvar_element}">${jvar_element} <i class="fas fa-check"></i></div>
</j:forEach>
</div>
</div>
</div>
</div>
</section>
*************************************************************************************
Ui page Client script
function selectMulti(item) {
// Display the item in the multiselect input field
$j("#" + $j(item).attr("value")).toggleClass("selected-item");
// Add the active-item class on the currently clicked item
$j(item).toggleClass("active-item");
// Show the check icon on the currently clicked item
$j(item).find(".fa-check").toggleClass("active-item-icon");
setValueOfHiddenPurposeField();
}
please find the attached screen shotSolved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2021 04:05 AM
Hi,
I am able to achieve using this
HTML:
<?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 jelly="true" object="true" var="jvar_arr">
var arr = ['Volvo','Audi','Opel','Nissan'];
arr;
</g:evaluate>
<select name="cars" id="cars" multiple="true">
<j:forEach items="${jvar_arr}" var="jvar_element">
<option value="${jvar_element}">${jvar_element}</option>
</j:forEach>
</select>
</j:jelly>
Output:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2021 11:48 PM
Hi Reddy,
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>
Else, you can also refer to this link : https://community.servicenow.com/community?id=community_question&sys_id=28b8909bdb2d9300c310fb651f9619e9
Please mark my answer as Correct & Helpful, if applicable.
Thanks
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2021 02:29 AM
Hi
Thanks for giving reply.
I have tried as you suggested but it's not working for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-18-2021 01:14 AM
If the options are coming from a table. You can make use of sn-record-picker and add an attribute multiple="true" for multi select
<sn-record-picker field="user" table="'sys_user'" display-field="'name'" value-field="'sys_id'" search-fields="'name'" page-size="100" ></sn-record-picker>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-19-2021 12:34 AM
Hi,
Sorry can you explain what is required?
If you want multiple values to be selected then why not use checkbox
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader