- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2018 07:20 AM
Hello All,
I am trying to set value of list collector in selected while page is loading,
Below is my code,
function onLoad() {
//Type appropriate comment here, and begin script below
var varName = 'update_group_test';//Variable name
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 = [];
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);
}
I referred below ServiceNow guru link ,
https://www.servicenowguru.com/scripting/client-scripts-scripting/move-list-collector-options/
Please help
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2018 07:46 AM
than easiest way will be adding default value on list collector variable. If is reference field than sys_id of record. if more than 1 record than separated by comma.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2018 07:21 AM
Are you trying to do this on portal side?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2018 07:28 AM
Hello Mike,
I am trying to do on both sides on portal and also from backend.
Thanks,
Kalpesj

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2018 07:37 AM
Are you trying to set default selection to right when it's loaded than user can remove it if they don't want it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2018 07:45 AM
Yes, I am trying to set up default selection of right bucket while loading the form. after that users can remove if they want to do.