- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-18-2016 11:44 AM
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?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2016 04:31 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2016 10:48 AM
Hi Rahul,
On observing your script, the below line is the problem -
var selectedIDs = ["c3f008330a0a3c44018a49dc3ecbe029","75f1ef0a7cd9d640773324a4a9bfd8b1"];
selectedIDs that will be passed to moveSelectedOptions is Index number in the leftbucket not the sys_ids. Its like from the list I want to select 3, 4 element. Thats what it says.
I understood your requirement, when a particular value gets selected and you want to two values also to be moved to right slush bucket -
I have did entire coding in my local instance, by constructing a catalog item and having a list collector referring to sys_user table-
If Abel Tuter was selected then ACME Employee and ACME ITIL will be added to right slushbucket
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);
break;
}
}
}
The above script will whenever Abel Tuter is selected, the right slushbucket gets cleared and those two users will be populated
You can modify the script as per your need.
If you want to know more functions, you can check right click -> Inspect element -> Sources
Hopefully this script should help you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2016 06:14 AM
Hi Srikanth,
Solution is working fine, however there is one problem. When i double click on "Consultant Pharmacist package" in left bucket, all the required applications in this package are moving to right side bucket but the control or selection is not actually moving to right side automatically. So when i save the form, there is nothing selected in that bucket.
Temporary solution i provided to end users, is to manually select any one of the CI in the right side bucket and then save the form.
Do we have any solution for this problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-21-2016 08:06 AM
Its good to know that you have found a workaround, there are many functions available as part of DOM - i will update you, once I find the proper function which brings the focus and click on one option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2016 04:31 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-22-2016 02:06 PM
Thanks a lot Srikanth..It was really useful.