Slushbucket Archives - ServiceNow Guru https://servicenowguru.com/tag/slushbucket/ ServiceNow Consulting Scripting Administration Development Tue, 28 May 2024 21:34:30 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.2 https://servicenowguru.com/wp-content/uploads/2024/05/cropped-SNGuru-Icon-32x32.png Slushbucket Archives - ServiceNow Guru https://servicenowguru.com/tag/slushbucket/ 32 32 Creating a Custom Slushbucket Popup Dialog https://servicenowguru.com/system-ui/creating-custom-slushbucket-popup-dialog/ https://servicenowguru.com/system-ui/creating-custom-slushbucket-popup-dialog/#comments Tue, 04 Jan 2011 16:29:41 +0000 https://servicenowguru.wpengine.com/?p=3194 Happy New Year! Hopefully everybody had a great holiday. Mine was spent mostly helping my kids to break in some new toys :). I did get some time to play with some new Service-now ideas as well. I’ll be sharing some very cool stuff here on SNCGuru over the next couple of weeks. I’ve seen

The post Creating a Custom Slushbucket Popup Dialog appeared first on ServiceNow Guru.

]]>
Happy New Year! Hopefully everybody had a great holiday. Mine was spent mostly helping my kids to break in some new toys :). I did get some time to play with some new Service-now ideas as well. I’ll be sharing some very cool stuff here on SNCGuru over the next couple of weeks.
I’ve seen a couple requests recently for a way to allow users to select items from a slushbucket popup dialog. The most common reason for this is to help manage manual group approvals on a task record. If you’ve worked with group approvals at all, you’ve probably noticed that they work a little bit differently than regular approval records do. Group approval records are really just task records so you can’t just hit an ‘Edit’ button and add groups to be approvers on a task. Instead, you have to repeatedly click the ‘New’ button and create a new task record for each approval group. Normally this isn’t an issue because group approvals are typically managed in workflow but if you’re manually adding a lot of these, the process can be fairly tedious.
This article shows how you can provide a better UI by creating a slushbucket popup dialog that allows users to select one or many groups to add as approvers on a task. Even though the solution is designed for a specific use case, I’ve tried to make the example shown here generic enough so that you can easily modify it for other uses as well.


The first piece to this solution is to create a trigger for the dialog. For this solution, a UI action probably makes the most sense. The end user will click a UI action to display the popup dialog and make the necessary selections there.

‘Add Approval Groups’ UI Action
Name: Add Approval Groups
Client: true
Form link: true
OnClick: addApprovalGroups()
Condition: gs.hasRole(‘itil’)
Script:

function addApprovalGroups(){
   //Open a dialog window to select Approval Groups
   var dialog = new GlideDialogWindow('add_approval_groups');
   dialog.setTitle('Add Approval Groups');
   dialog.setPreference('sysparm_groupQuery', 'active=true');
   dialog.render();
   //Make sure to not submit the form when button gets clicked
   return false;
}

The UI action opens the dialog with a call to a specific UI page. The UI page is what contains most of the logic for the slushbucket. It includes the actual HTML (which pulls in the slushbucket and UI buttons from UI macros) as well as the client script that loads the groups and makes a call to insert group approval records.

‘add_approval_groups’ UI Page
Name: add_approval_groups
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">
   <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/>
         </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:

//Called when the 'OK' button gets clicked
function continueOK(){
   //Get the selected values from the right slushbucket
   var values = slush.getValues(slush.getRightSelect());
   //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);
}

//Called when we get a response from the 'continueOK' function
function addGroupResponse(){
   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;
}

//Called when the form loads
addLoadEvent(function(){
   //Load the groups when the form loads
   slush.clear();
   var ajax = new GlideAjax('GroupSelectAjax');
   ajax.addParam('sysparm_name', 'getGroups'); 
   ajax.getXML(loadResponse);
   return false; 
});

//Called when we get a response from the 'addLoadEvent' function
function loadResponse(response){
   //Process the return XML document and add groups 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'));
   }
}

Many times, you can stop with the UI page. In this case, it makes sense for us to do some of our heavy-lifting for populating the groups in the slushbucket and creating group approval records at the server. The client scripts in the UI page make GlideAjax calls to the functions in a script include. The script include performs the query and returns an XML response back to the client so that it can continue.

‘GroupSelectAjax’ Script Include
Name: GroupSelectAjax
Client callable: true
Script:

var GroupSelectAjax = Class.create();

GroupSelectAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, {
   //Get and return a list of groups (name and sys_id)
   getGroups: function() {  
      var gr = new GlideRecord("sys_user_group");
      gr.orderBy('name');
      gr.addQuery('active', true);  
      gr.query(); 

      //Add the available groups to select from
      while (gr.next()) {
         var item = this.newItem();
         item.setAttribute('value', gr.getValue('sys_id'));
         item.setAttribute('text', gr.getValue('name'));
      }
   },

   //Take a taskID and group sys_id values and add 'sysapproval_group' records
   groupsAdd: function() {
      var taskID = this.getParameter('sysparm_taskID');
      var values = this.getParameter('sysparm_values').split(',');
      //Iterate through the group sys_id values
      for(x in values){
         var rec = new GlideRecord('sysapproval_group');
         rec.initialize();
         rec.parent = taskID;
         rec.assignment_group = values[x];
         rec.approval = 'requested';
         rec.insert();
      }    
   }
});

The post Creating a Custom Slushbucket Popup Dialog appeared first on ServiceNow Guru.

]]>
https://servicenowguru.com/system-ui/creating-custom-slushbucket-popup-dialog/feed/ 36
Change the Size of a List Collector Slushbucket Variable https://servicenowguru.com/client-scripts-scripting/change-size-list-collector-slushbucket-variable/ https://servicenowguru.com/client-scripts-scripting/change-size-list-collector-slushbucket-variable/#comments Wed, 24 Nov 2010 08:33:06 +0000 https://servicenowguru.wpengine.com/?p=2830 List collector variables are a great way to collect multiple pieces of information about referenced records in a single variable in the Service Catalog. One complaint I get about these variables is that they take up a lot of space on the screen. While there’s not a lot you can do with regular slushbuckets in

The post Change the Size of a List Collector Slushbucket Variable appeared first on ServiceNow Guru.

]]>
List collector variables are a great way to collect multiple pieces of information about referenced records in a single variable in the Service Catalog. One complaint I get about these variables is that they take up a lot of space on the screen. While there’s not a lot you can do with regular slushbuckets in the system, List Collector variables have a little bit more flexibility because they can be manipulated with client scripts. Check out the SNGuru List Collector archives for more examples of cool List Collector modifications you can use.

In this article I’ll show you how you can reclaim some of that Service Catalog screen real estate by modifying the size of a list collector variable using a catalog client script.

Important note!!! Changing the size of your list collector has NO effect on the number of items displayed in that list collector. The number of entries in list collectors in your system is controlled by a global property. You can increase the number of entries in your filter, but that also incurs a performance hit when working with slushbucket filters since that whole number of items needs to be loaded every time in the slushbucket. You really don’t want to increase this number to much more than the default of 100.

The property is called ‘glide.xmlhttp.excessive’ and is documented here. It applies to all slushbuckets in your system (including those for list collectors).

The script is pretty simple. All you need to do is give it the name of the list collector variable you would like to resize, along with the width and height. In my testing I’ve found that the look of the variable can start to get kind of messy if you set a width less than 250 so I wouldn’t go any smaller than that.

As of the Winter 2010 Stable 2 release, it is now possible to hide the filter portion of a list collector variable completely. This can be accomplished by adding the ‘no_filter’ attribute to the ‘Attributes’ field on the variable form.
function onLoad(){
	var varName = 'YOUR_VARIABLE_NAME_HERE';
	var height = '100'; //Optional
	var width = '250'; //Optional
	try{
		//Get the left and right bucket input elements
		var leftBucket = $(varName + '_select_0');
		var rightBucket = $(varName + '_select_1');
		
		//If the element exists
		if(leftBucket){
			//Adjust the bucket height (default is 300px)
			if(height){
				leftBucket.style.height = height + 'px';
				rightBucket.style.height = height + 'px';
			}
			
			if(width){
				//Adjust the bucket width (default is 340px)
				leftBucket.style.width = width + 'px';
				rightBucket.style.width = width + 'px';
                                //Fix Fuji/Geneva width issue
                                leftBucket.up('.slushbucket').style.width = width*2 + 100 + 'px';
			}
			
			//Fix the expanding item preview issue
			$(varName + 'recordpreview').up('td').setAttribute('colSpan', '3');
		}
	}catch(e){}
}

Here’s the result!

The post Change the Size of a List Collector Slushbucket Variable appeared first on ServiceNow Guru.

]]>
https://servicenowguru.com/client-scripts-scripting/change-size-list-collector-slushbucket-variable/feed/ 28
Move List Collector Options https://servicenowguru.com/client-scripts-scripting/move-list-collector-options/ https://servicenowguru.com/client-scripts-scripting/move-list-collector-options/#comments Tue, 22 Jun 2010 15:42:14 +0000 https://servicenowguru.wpengine.com/?p=1758 Here’s a cool catalog client script that I figured out for a client. It allows you to move one or more selected options from one side of a list collector variable slushbucket to another. Using the script is pretty straight forward. Just supply the name of the list collector variable you are working with, and

The post Move List Collector Options appeared first on ServiceNow Guru.

]]>
Here’s a cool catalog client script that I figured out for a client. It allows you to move one or more selected options from one side of a list collector variable slushbucket to another. Using the script is pretty straight forward. Just supply the name of the list collector variable you are working with, and then make sure you provide an array of option IDs to move from one side to another. The option IDs need to be added to the ‘selectedIDs’ array in the middle chunk of code. The code below is set up to move ALL options in the right column of a slushbucket to the left.

//Name of variable to move options from
var varName = 'YOUR_VARIABLE_NAME_HERE';
var leftBucket = gel(varName + '_select_0');
var rightBucket = gel(varName + '_select_1');
var selectedOptions = rightBucket.options;

//Get an array of all option IDs to move
var selectedIDs = new Array();
var index = 0;
for(var i = 0; i < selectedOptions.length; i++){
   selectedIDs[index] = i;
   index++;
}

//Move all returned options from right to left bucket and sort the results
//Switch 'rightBucket' and 'leftBucket' to move from left to right
moveSelectedOptions(selectedIDs, rightBucket, leftBucket, '--None--');
//Sort the resultant options in the left bucket
sortSelect(leftBucket);

The post Move List Collector Options appeared first on ServiceNow Guru.

]]>
https://servicenowguru.com/client-scripts-scripting/move-list-collector-options/feed/ 35
Customizing the Slushbucket https://servicenowguru.com/system-ui/customizing-slushbucket/ https://servicenowguru.com/system-ui/customizing-slushbucket/#comments Thu, 25 Feb 2010 20:47:01 +0000 https://servicenowguru.wpengine.com/?p=937 The term ‘Slushbucket’ is used in Service-now to refer to a couple of places in the system… The popup window view that you see when you click the ‘Edit’ button from a related list at the bottom of a form. The interface used to display any ‘List collector’ service catalog variable A question that comes

The post Customizing the Slushbucket appeared first on ServiceNow Guru.

]]>
The term ‘Slushbucket’ is used in Service-now to refer to a couple of places in the system…

  • The popup window view that you see when you click the ‘Edit’ button from a related list at the bottom of a form.
  • The interface used to display any ‘List collector’ service catalog variable

A question that comes up pretty often is “Can I customize the slushbucket to display more information about the items shown?”. The answer to this is ‘YES’ but it might not work exactly like you think it should. Currently, you only have control over the field values shown below the slushbucket when you click on any item to highlight it. The actual values shown in the slushbucket are determined by the ‘display’ field on the dictionary entry for the referenced table. Most people would like to display multiple columns worth of data for items within the slushbucket itself, but this is not possible yet.

Slushbucket Normal

Adding additional fields below the slushbucket is a very simple customization though. All you have to do is personalize the ‘sys_ref_list’ list view view for the table being displayed in the slushbucket.

So, if I was displaying a slushbucket with records from the ‘Group’ (‘sys_user_group’) table would need to personalize the ‘sys_ref_list’ list view for that table. There are a couple of ways you could do this, but the way I’ll show here ensures that your updates get captured correctly so they can be migrated to another instance if necessary.

For the ‘Group’ (‘sys_user_group’) table navigate to the following URL in your browser…

https://[YOUR_INSTANCE_URL]/sys_user_group_list.do?sysparm_view=sys_ref_list

This same convention can be used for any table in your system. Simply replace ‘sys_user_group’ with the table you want to personalize. Once you’re there, just right-click the list header and personalize the list.

Slushbucket sys_ref_list

Slushbucket Personalize List View

Any columns you add to the personalized ‘sys_ref_list’ view for a given table will be displayed below any slushbucket for that table.

Slushbucket Personalized

The post Customizing the Slushbucket appeared first on ServiceNow Guru.

]]>
https://servicenowguru.com/system-ui/customizing-slushbucket/feed/ 35