Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Reference SlushBucket in Client Script of UI Page

Trevor Muhl
Kilo Sage

Hello everyone,

I have encountered an issue with implementing a slush bucket on a UI page. According to the Custom Slushbucket Setup guide, the variable 'slush' is defined by line 11 of the client script section. Whenever I use 'slush', it is not defined as I would expect. How do I define it?

Another thread suggests the following method to define references to the slush bucket:

  1.     var varName = 'server_list';  
  2.     var leftBucket = gel(varName + '_select_0');  
  3.     var rightBucket = gel(varName + '_select_1');

This makes sense. However, 'leftBucket' and 'rightBucket' are null within my code. Am I missing something obvious? The following is the code contained in my UI page. Everything else works as expected:

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">

              var userGr = new GlideRecord('sys_user');

              userGr.addQuery('active', true);

              userGr.query();  

      </g:evaluate>

      <table border='0'>

              <tr>

                      <td>

                              <g:ui_slushbucket name="sb" left_header="Available Users" right_header="Selected User(s)" up_down="true">

                                      <j:while test="${userGr.next()}">

                                                  <option value="${userGr.sys_id}"> ${userGr.name} </option>

                                      </j:while>

                              </g:ui_slushbucket>

                      </td>

              </tr>

              <tr>

                      <td align='right'>  

                              <g:dialog_button_ok ok='return actionOk()' ok_type='button' />  

                      </td>  

              </tr>

      </table>

</j:jelly>

Client Script

function actionOk() {

      try {

      // alert('Selected users have been saved.');

      var varName = 'sb';

      var leftBucket = gel(varName + '_select_0');  

      var rightBucket = gel(varName + '_select_1');

      var values = rightBucket.getRightSelect();

             

      alert("Values: " + values);

      } catch(e) {alert("ERROR: " + e.message);}

}

Thank you!

1 ACCEPTED SOLUTION

Trevor Muhl
Kilo Sage

Apparently, I was indeed missing something obvious. The name you define for the slushbucket in the HTML code is then defined within the scope of the client script. I was certain that I tried this, but issues caused by other tweaks may have prevented it from working at the time.



I hate to be "that guy that solves his own question", but here it is.  


View solution in original post

1 REPLY 1

Trevor Muhl
Kilo Sage

Apparently, I was indeed missing something obvious. The name you define for the slushbucket in the HTML code is then defined within the scope of the client script. I was certain that I tried this, but issues caused by other tweaks may have prevented it from working at the time.



I hate to be "that guy that solves his own question", but here it is.