- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 09:25 PM
Hi,
I'm in a need of creating an empty list collector. Since we cannot initiate an empty list controller, what i'm going to do is run an onLoad script to remove all the elements from the List collector and add it manually via a script.
Can i do this ? and how to do that ?
All the way i searched i only found some thing called "move" which moves elements from left to right and vise versa.
Thank you.
/Sandaru
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 09:29 PM
Here is how you can do it. You will have use filter string sys_id=''; This will load you with empty list collector
function onLoad() {
//Apply a default filter to the list collector variable
var collectorName = 'configuration_items';
var filterString = 'sys_id='+'';
//Hide the list collector until we've set the filter
g_form.setDisplay(collectorName, false);
setCollectorFilter();
function setCollectorFilter(){
//Test if the g_filter property is defined on our list collector.
//If it hasn't rendered yet, wait 100ms and try again.
if(typeof(window[collectorName + 'g_filter']) == 'undefined'){
setTimeout(setCollectorFilter, 100);
return;
}
//Find the filter elements
var fil = gel('ep');
//Hide the filter elements by un-commenting the following lines
/*fil.rows[0].style.display = 'none';
fil.rows[1].style.display = 'none';
fil.nextSibling.rows[0].style.display = 'none'; //Filter description text*/
//Reset the filter query
window[collectorName + 'g_filter'].reset();
window[collectorName + 'g_filter'].setQuery(filterString);
window[collectorName + 'acRequest'](null);
//Redisplay the list collector variable
g_form.setDisplay(collectorName, true);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 09:47 PM
which release are you on? Can you attach a snapshot of your script

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 09:57 PM
the second one should also work and it is much easier to implement.Try this
setCollectorFilter();
function setCollectorFilter(){
var varName = 'YOUR_VARIABLE_NAME_HERE';
//Test if the g_filter property is defined on our list collector.
//If it hasn't rendered yet, wait 100ms and try again.
if(typeof(window[varName + 'g_filter']) == 'undefined'){
setTimeout(setCollectorFilter, 100);
return;
}
var leftBucket = gel(varName + '_select_0');
var rightBucket = gel(varName + '_select_1');
rightBucket.options.length=0;
leftBucket.options.length=0;
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 10:05 PM
Here is the tested one. this should work for u too
function onLoad() {
setTimeout(setCollectorFilter, 3000);
function setCollectorFilter(){
var varName = 'list collector name';
var leftBucket = gel(varName + '_select_0');
var rightBucket = gel(varName + '_select_1');
rightBucket.options.length=0;
leftBucket.options.length=0;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2016 10:48 PM
Hi Abhinay, I was wondering if you've happened to have worked with 2 list collector(LC) variables on a single cat item ? I am actually stuck where in the second LC variable is just adding the sysID of the first LC variable in its filter & this is resulting in 2 blank slush buckets.
But if there is only 1 value in the first LC var, the second LC var seems to work just fine. Issue occurs only when I add more values in the first LC var...Your thoughts on this mate ?