Slush Bucket

Rahul Kathuria
Tera Expert

Hi,

We have a slush bucket field named "Please select which access you would like". The variable type is "List collector" and it is referencing the CMDB applications table.

Requirement: In the "slush bucket" for the service catalog access RITMs…..we are thinking to have an option called " Consultant Pharmacist Bundle".   When selected,   a java script will run that reads a table that contains the apps that are defined to this bundle, and then populates those apps on the right side "slush" for access…???     As we add more apps to the bundle, the program won't need to change because we're reading from a dynamic table, versus a hard coded list

Any help on this will be appreciated?

1 ACCEPTED SOLUTION

I have found the fix for the slushbucket,


the line leftbucket.onchange(); will refresh the list again and there is no need for them to click on the slushbucket again


Line number 33, thats the addition I did


Change your code to below -



function onChange(control, oldValue, newValue, isLoading) {


    if (isLoading || newValue == '') {


          return;


    }


  //Abel Tuter = 62826bf03710200044e0bfc8bcbe5df1;


  //ACME Employee = 107c14341f1310005a3637b8ec8b7008;


  //ACME ITIL = 797d14341f1310005a3637b8ec8b7010;


  var varName = "userlist";


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


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




  var selectedOptions = rightBucket.options; //get the options in right bucket


  //Get an array of all option IDs to move


  var selectedIDs = new Array(); //construct the id array [0,1,2,...]


  var index = 0;


  for(var i = 0; i < selectedOptions.length; i++){


      selectedIDs[index] = i;


      index++;


  }



  for(var i = 0; i< selectedOptions.length; i++){


  if(selectedOptions[i].value == '62826bf03710200044e0bfc8bcbe5df1'){//check for Abel Tuter


  moveSelectedOptions(selectedIDs, rightBucket, leftBucket); //move the options


  //remove none option from right


  if(rightBucket.options.length == 1 && rightBucket.options[0].text == '--None--'){


      rightBucket.options.length = '0';


  }


  //Add the value that you want to add here, rightbuckt, sysid, displayValue


  addOption(rightBucket, "107c14341f1310005a3637b8ec8b7008", "ACME Employee");


  addOption(rightBucket, "797d14341f1310005a3637b8ec8b7010", "ACME ITIL");


  sortSelect(rightBucket);


  leftBucket.onchange();


  break;


  }


  }


}








Mark it has correct, if it has resolved the issue


View solution in original post

13 REPLIES 13

ghsrikanth
Tera Guru

You can write a client catalog script - onChange on Consultant Pharmacist Bundle


onChange the script retrieves the data from the table through GlideAjax call and return a comma separated sys_ids


And assign the sys_ids to the List Collector



Please look into the Glide Ajax article in Wiki - GlideAjax - ServiceNow Wiki



Mostly the g_form.setValue(); should work for List Collector right slush bucket, if not you can always go for DOM manipulation as show by SN guru-


Move List Collector Options - ServiceNow Guru



Mark if it is helpful or correct, feedback is appreciated


Rahul Kathuria
Tera Expert

Srikanth, instead of GlideAjax call, can't i use the simple glide query to fetch the results?


ghsrikanth
Tera Guru

Yes you can use GlideRecord query in Client Side - but there are few restrictions and its adivisable to use GlideAjax as you can make it asynchronous, anyhow you can implement with whatever you feel comfortable


FYI, Client Side GlideRecord - ServiceNow Wiki



Mark if it is helpful or correct, feedback is appreciated


Srikanth, i am using the below on change client script, however it is not working. Can you please let me know what am i doing wrong here?



//sys id of consultant package application- 8ed97438d8121a40c64c9be40e87a4b8- when i select this application and move it to right side slush bucket


// i want "c3f008330a0a3c44018a49dc3ecbe029","75f1ef0a7cd9d640773324a4a9bfd8b1" also to be moved to right side slush bucket. these are sys id's of 2 different applications.


-----------------------------------------------------------


function onChange(control, oldValue, newValue, isLoading) {


  if(isLoading){


    return;


  }


    //Name of variable to move options from


var varName = 'software_choices';


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


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


var selectedOptions = leftBucket.options;



if (selectedOptions.value == '8ed97438d8121a40c64c9be40e87a4b8')


{




//Get an array of all option IDs to move


var selectedIDs = ["c3f008330a0a3c44018a49dc3ecbe029","75f1ef0a7cd9d640773324a4a9bfd8b1"];



}



//Move all returned options from left to right bucket and sort the results


//Switch 'rightBucket' and 'leftBucket' to move from left to right


moveSelectedOptions(selectedIDs, leftBucket, rightBucket, '--None--');


//Sort the resultant options in the left bucket


sortSelect(rightBucket);


  }