What are Slushbucket methods in script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2015 05:51 AM
Hi all,
I miss documentation to Slushbucket. I have macro with <g:ui_slushbucket/> element and I would like to know available methods for slushbucket.
I found a method addLeftChoice() or clear() or getRightSelect() but I miss method for adding right choices.
Could you please point me to some documentation or show me some next methods?
Thanks!
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 05:44 AM
Can you be more specific? What problem are you having and where?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 06:07 AM
My apologies - I posted before coffee.
We've created a custom slushbucket and are hoping to expand the columns of text. We can only expand so far and then the space between the text columns increases instead.
The UI Action that calls the UI Page:
function addExts(){
//Open a dialog window to select Approval Groups
var dialog = new GlideDialogWindow('x_enig_quote_extrm_add_extention');
dialog.setTitle('Add Extentions/Ajouter des extensions');
dialog.setPreference('sysparm_groupQuery', 'active=true');
dialog.setSize(1000,400);
dialog.render();
return false;
}
Here's the HMTL from the UI Page:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<TABLE width="100%" >
<tr>
<td align="right">
<p><label for="search_field" style="display:inline">Extension Group/Groupes d'extensions de garantie: </label>
<input id="search_field" type="text" name="search_field" value=''/></p>
</td>
</tr>
<tr>
<td align="right">
<button onclick="myFunction()">Search/Rechercher</button>
</td>
</tr>
</TABLE>
<TABLE >
<TR>
<TD>
<br>Select Extension(s)/Sélect extensions </br>
</TD>
</TR>
<TR>
<TD>
<g:ui_slushbucket/>
<script>
//Time out functiuon to generate results when the dialog 1st runs-->
setTimeout("myFunction()", 0.1);
</script>
</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>
And the Client Script where our changes are in lines 1 - 6:
//BORDER="0" width="100%"
addLoadEvent(function(){
//jQuery('.slushselect').attr("style", "width: 950px"); //expands the ui_slushbucket macro
jQuery('.slushselect').attr("width", "400px");
jQuery('.slushselect').attr("size", "5");
GlideDialogWindow.get().onResize();//recenter the GDW after resizing it.
});
function myFunction(){
gettingExt();
}
function gettingExt(){
//jQuery('.slushselect').attr("style", "width: 400px"); //expands the ui_slushbucket macro
//GlideDialogWindow.get().onResize();
//
slush.clear();
var search = gel('search_field').value;
var search1 = g_form.getValue("company_code");
var search2 = g_form.getValue("print_language");
//var search1 = gel('search_field1').value;
//var search2 = gel('search_field2').value;
//var search3 = gel('search_field3').value;
//var search4 = gel('search_field4').value;
//var search5 = gel('search_field5').value;
slush.clear();
var ajax = new GlideAjax('ExtremeQuoteAjaxScripts');
ajax.addParam('sysparm_name', 'getExtResults');
ajax.addParam('sysparm_search', search);
ajax.addParam('sysparm_search1', search1);
ajax.addParam('sysparm_search2', search2);
//ajax.addParam('sysparm_search4', search4);
//ajax.addParam('sysparm_search5', search5);
//ajax.addParam('lang', language);
//alert("got this far2");
ajax.getXML(loadResponse);
return false;
}
//Called when we get a response from the 'addLoadEvent' function
function loadResponse(response){
//document.getElementById('loading_image').style.display= 'none';
//Process the return XML document and add techs to the left select
var xml = response.responseXML;
var e = xml.documentElement;
var items = xml.getElementsByTagName("item");
if(items.length == 0){
return;
}
//Loop through item elements and add each item to left slushbucket
for (var i = 0; i < items.length; i++) {
var item = items[i];
slush.addLeftChoice(item.getAttribute('value'), item.getAttribute('text'));
}
}
//Called when the 'OK' button gets clicked
function continueOK(){
var msg1 = getMessage('one.item.selected');
var msg2 = getMessage('refresh.coverages.list');
//Get the selected values from the right slushbucket
var values = slush.getValues(slush.getRightSelect());
//Get the sys_id of the current record
//error with below
var taskID = g_form.getUniqueValue();
//Make sure we have at least one selection
if(values == '' ){
alert(msg1);
return;
}
//Build Many-To-Many from selected Ext
var search1 = g_form.getValue("company_code");
var search2 = g_form.getValue("print_language");
var ajax = new GlideAjax('ExtremeQuoteAjaxScripts');
ajax.addParam('sysparm_name', 'CreateExts');
ajax.addParam('sysparm_locID', taskID);
ajax.addParam('sysparm_values', values);
ajax.addParam('sysparm_search1', search1);
ajax.addParam('sysparm_search2', search2);
ajax.getXML('addCollectionResponse');
GlideDialogWindow.get().destroy();
alert(msg2);
}
//Called when we get a response from the 'continueOK' function -- not actually using this
function addCollectionResponse(){
GlideDialogWindow.get().destroy();
//GlideList2.get('').setFilterAndRefresh('');
return false;
}
//Called when the 'Cancel' button gets clicked
function continueCancel(){
//Close the dialog window
GlideDialogWindow.get().destroy();
return false;
}
And here's the result:
Thanks for the quick reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 06:29 AM
Also what version of ServiceNow is this in? Are you inside Catalog or a regular form view or portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 07:23 AM
We're on Istanbul. It's on a regular form view.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2017 09:50 AM
Ok the fix is to remove the table since nowadays the ui_slushbucket is using Bootstrap.
UI Page
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<div class="container-fluid">
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8 col-xs-12">
<label for="search_field" style="display:inline">Extension Group/Groupes d'extensions de garantie: </label>
<input id="search_field" type="text" name="search_field" value=''/>
<div class="pull-right">
<button onclick="myFunction()">Search/Rechercher</button>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
Select Extension(s)/Sélect extensions:
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12"></div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<g:ui_slushbucket />
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="pull-right">
<g:dialog_buttons_ok_cancel ok='return continueOK()' cancel="return continueCancel()" ok_type='button' cancel_type="button" />
</div>
</div>
</div>
</div>
<!--
<TABLE width="100%" >
<tr>
<td align="right">
<p><label for="search_field" style="display:inline">Extension Group/Groupes d'extensions de garantie: </label>
<input id="search_field" type="text" name="search_field" value=''/></p>
</td>
</tr>
<tr>
<td align="right">
<button onclick="myFunction()">Search/Rechercher</button>
</td>
</tr>
</TABLE>
<TABLE >
<TR>
<TD>
<br>Select Extension(s)/Sélect extensions </br>
</TD>
</TR>
<TR>
<TD>
<g:ui_slushbucket/>
</TD>
</TR>
<TR>
<TD align="right">
<g:dialog_buttons_ok_cancel ok='return continueOK()' cancel="return continueCancel()" ok_type='button' cancel_type="button"/>
</TD>
</TR>
</TABLE>
-->
<script>
//Time out functiuon to generate results when the dialog 1st runs-->
setTimeout("myFunction()", 0.1);
</script>
</j:jelly>
and then also edit the ui_slushbucket macro(s):
<?xml version="1.0" encoding="utf-8"?>
<!-- slushbucket creates its own table -->
<j:jelly trim="true" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:macro name="slush" left_header="${gs.getMessage('Available')}" right_header="${gs.getMessage('Selected')}" up_down="false"/>
<script>
var ${jvar_name};
addLoadEvent(function() {
${jvar_name} = new SlushBucket('${jvar_name}');
});
</script>
<div id="${jvar_name}" class="container-fluid slushbucket">
<div class="row form-group">
<div class="col-lg-6 col-md-6 col-xs-6">
<div class="glide-list">
<label for="${jvar_name}_left">${jvar_left_header}</label>
<div class="slushbucket-top">
<!-- left selection -->
<select id="${jvar_name}_left"
name="${jvar_name}_left" class="slushselect form-control"
multiple="yes" size="10" width="120"
ondblclick="${jvar_name}.moveLeftToRight();">
<!-- option that gets erased onload -->
<options>--</options>
<!-- you can build your options list inline... -->
<g:insert/>
</select>
<div class="button-column" id="addRemoveButtons">
<A title="${gs.getMessage('uppercase_add')}" class="btn btn-default icon-chevron-right"
onclick="${jvar_name}.moveLeftToRight();" href="javascript:void(0)">
<span class="sr-only">
${gs.getMessage('uppercase_add')}
</span>
</A>
<A title="${gs.getMessage('Remove')}" class="btn btn-default icon-chevron-left"
onclick="${jvar_name}.moveRightToLeft();" href="javascript:void(0)">
<span class="sr-only">
${gs.getMessage('Remove')}
</span>
</A>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-xs-6">
<div class="glide-list">
<label for="${jvar_name}_right">${jvar_right_header}</label>
<div class="slushbucket-top slushbody">
<!-- left selection -->
<select id="${jvar_name}_right"
name="${jvar_name}_right" class="slushselect form-control"
multiple="yes" size="10" width="120"
ondblclick="${jvar_name}.moveRightToLeft();">
<!-- option that gets erased onload -->
<option>--</option>
</select>
<div id="upDownButtons" class="button-column">
<j:if test="${jvar_up_down != 'false'}">
<A title="${gs.getMessage('Move up')}" class="btn btn-default icon-chevron-up"
href="javascript:void(0)"
onclick="${jvar_name}.moveUp();" ondblclick="${jvar_name}.moveUp();">
<span class="sr-only">
${gs.getMessage('Move up')}
</span>
</A>
<A title="${gs.getMessage('Move down')}" class="btn btn-default icon-chevron-down"
href="javascript:void(0)"
onclick="${jvar_name}.moveDown();" ondblclick="${jvar_name}.moveDown();">
<span class="sr-only">
${gs.getMessage('Move down')}
</span>
</A>
</j:if>
</div>
</div>
</div>
</div>
</div>
</div>
</j:jelly>
And you no longer need the addLoadEvent to resize anything. (which is great). This is another great answer from my personal UI Guru, Mr Jeremy Mandle. He's one of our best over here at Acorio.