- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2017 07:13 AM
I'm working with ServiceNow Guru's excellent example of a custom slushbucket.
I've got the slushbucket working with the list of groups to be selected. At the end of the UI Page HTML code, the value of the right-side of the slushbucket should be passed to the client script. That's not happening and I'm at a loss to see how it could happen.
HTML Code:
<?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>
//Get all groups
var gr = new GlideRecord('sys_user_group');
gr.addQuery('active', true);
gr.orderBy('name');
gr.query();
</g:evaluate>
<TABLE BORDER="0">
<TR>
<TD>
Please select the groups you wish to add as approvers.
</TD>
</TR>
<TR>
<TD>
<!-- Include the 'ui_slushbucket' UI macro -->
<g:ui_slushbucket name="sb" left_header="Groups" right_header="Selected">
<j:while test="${gr.next()}">
<option value="${gr.sys_id}"> ${gr.name} </option>
</j:while>
</g:ui_slushbucket>
</TD>
</TR>
<TR>
<TD align="right">
<!-- Include the 'dialog_buttons_ok_cancel' UI macro -->
<g:dialog_buttons_ok_cancel ok="return continueOK()" cancel="return continueCancel()" ok_type="button" cancel_type="button"/>
</TD>
</TR>
</TABLE>
</j:jelly>
Client Script code:
//Called when the 'OK' button gets clicked
function continueOK(){
alert("client script"); // this alert appears so the Client Script IS being called.
//Get the selected values from the right slushbucket
var values = slush.getValues(slush.getRightSelect());
alert(values[0]); // this alert doesn't come up - neither as 'values[0]' or simply as 'values' or even as a text message.
//Get the sys_id of the current record
var taskID = g_form.getUniqueValue();
//Make sure we have at least one selection
if(values == ''){
alert("At least one group must be selected");
return;
}
//Add the group approval records
var ajax = new GlideAjax('GroupSelectAjax');
ajax.addParam('sysparm_name', 'groupsAdd');
ajax.addParam('sysparm_taskID', taskID);
ajax.addParam('sysparm_values', values);
ajax.getXML(addGroupResponse);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2017 12:08 PM
The slush object was undefined, which was causing issues with the script.
When I swapped 'slush' out for 'sb', the name attribute of your g:ui_slushbucket tag, I got the alerts to work.
Another thing to note is that the first position in the array was coming up as '--', so I changed the alert on line 9 to show the second position in the array.
//Called when the 'OK' button gets clicked
function continueOK(){
alert("client script"); // this alert appears so the Client Script IS being called.
//Get the selected values from the right slushbucket
var values = sb.getValues(sb.getRightSelect());
alert(values[1]); // this alert doesn't come up - neither as 'values[0]' or simply as 'values' or even as a text message.
//Get the sys_id of the current record
var taskID = g_form.getUniqueValue();
//Make sure we have at least one selection
if(values == ''){
alert("At least one group must be selected");
return;
}
//Add the group approval records
var ajax = new GlideAjax('GroupSelectAjax');
ajax.addParam('sysparm_name', 'groupsAdd');
ajax.addParam('sysparm_taskID', taskID);
ajax.addParam('sysparm_values', values);
ajax.getXML(addGroupResponse);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2017 11:51 AM
I'm wondering if this is an issue with the ui_slushbucket macro being in the global scope and my ui page is in a scoped application. I haven't been able to find any indication of how to reference the macro name properly except to say that:
var values = global.slush.getValues(slush.getRightSelect());
doesn't work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2017 12:08 PM
The slush object was undefined, which was causing issues with the script.
When I swapped 'slush' out for 'sb', the name attribute of your g:ui_slushbucket tag, I got the alerts to work.
Another thing to note is that the first position in the array was coming up as '--', so I changed the alert on line 9 to show the second position in the array.
//Called when the 'OK' button gets clicked
function continueOK(){
alert("client script"); // this alert appears so the Client Script IS being called.
//Get the selected values from the right slushbucket
var values = sb.getValues(sb.getRightSelect());
alert(values[1]); // this alert doesn't come up - neither as 'values[0]' or simply as 'values' or even as a text message.
//Get the sys_id of the current record
var taskID = g_form.getUniqueValue();
//Make sure we have at least one selection
if(values == ''){
alert("At least one group must be selected");
return;
}
//Add the group approval records
var ajax = new GlideAjax('GroupSelectAjax');
ajax.addParam('sysparm_name', 'groupsAdd');
ajax.addParam('sysparm_taskID', taskID);
ajax.addParam('sysparm_values', values);
ajax.getXML(addGroupResponse);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2017 06:31 AM
That worked perfectly. Thanks for your help.