- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 10:58 AM
Hi,
Wondering how do I pass multiple values to the client side. Previously below methods work. But now I need to pass multiple values to the client side, Could you please advise?
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:evaluate jelly="true">
var preMadeAssets = new GlideRecord('sys_user');
preMadeAssets.orderBy('name');
preMadeAssets.query();
var list = [];
while (preMadeAssets.next()) {
list.push({
sys_id: preMadeAssets.getUniqueValue(),
value: preMadeAssets.getDisplayValue()
});
}
</g:evaluate>
<form id="bucketStuff">
<div id="page">
<table width="100%">
<tr>
<td>
<input type="hidden" id='users' value="${JSON.stringify(list)}" />
<g:ui_slushbucket name="sb" />
Add this to the 'Client script':
addLoadEvent(function() {
sb.clear(); // without this, there will be a '--' item on the right side initially
JSON.parse(gel('users').value).forEach(function (user) {
sb.addRightChoice(user.sys_id, user.value);
});
// when you're done:
var sysIds = sb.getValues(sb.getRightSelect());
});
I currently have a UI page and below code is under <g:evaluate> , would like to pass 'selected' and 'list' to the client side in a similar way like above.
var persona_id = "4aabce6c77cbc1109284d78aef5a99f3";
var authorized_users = new GlideRecord("sn_nowebonding_authorized_user");
authorized_users.addQuery('persona', 'CONTAINS', persona_id);
authorized_users.query();
var selected = [];
while (authorized_users.next()){
selected.push({
sys_id: authorized_users.getUniqueValue();
value: authorized_users.customer_user.getDisplayValue();
});
}
var preMadeAssets = new GlideRecord('sys_user');
preMadeAssets.orderBy('name');
preMadeAssets.query();
var list = [];
while (preMadeAssets.next()) {
list.push({
sys_id: preMadeAssets.getUniqueValue(),
value: preMadeAssets.getDisplayValue()
});
}
Solved! Go to Solution.
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 11:26 AM
Hi,
You'd want to name your evaluate with a name such as:
<g2:evaluate var="jvar_gr" object="true" jelly="true">
then in your client script, it'll be accessible with:
$[jvar_gr]
You're unable to set multiple variables from one evaluate and only the last line will set this value. You can create an object to house everything and then in client script, iterate through that to break it apart, as needed.
Please mark reply as Helpful/Correct, if applicable. Thanks!
//
Respectfully,
Allen Andreas
ServiceNow Community MVP [2019-2022]
LinkedIn – Allenovation: YouTube Channel
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 11:26 AM
Hi,
You'd want to name your evaluate with a name such as:
<g2:evaluate var="jvar_gr" object="true" jelly="true">
then in your client script, it'll be accessible with:
$[jvar_gr]
You're unable to set multiple variables from one evaluate and only the last line will set this value. You can create an object to house everything and then in client script, iterate through that to break it apart, as needed.
Please mark reply as Helpful/Correct, if applicable. Thanks!
//
Respectfully,
Allen Andreas
ServiceNow Community MVP [2019-2022]
LinkedIn – Allenovation: YouTube Channel
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!