
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2014 05:16 AM
I have a catalog task with a UI policy, if Other is selected in the list collector a text box appears. If someone then choose a different request type that does not have the list collector the text box still appears. For a drop down I can run the following code to set the drop down back to --None--. Is there similar code I can use in a client script for a list collector. This does not appear to work for a list collector.
g_form.setValue('changetype', '', '--None--');
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2014 05:47 AM
I think this is actually what you're after.
» How to Move List Collector Options with a Catalog Client Script in Service-now
It's designed to work on the front-end catalog form though so I'm not sure how it will work on a back-end catalog task. In general, you'll have a much better experience with service catalog variables if you refrain from this type of manipulation on the back-end tasks. They're just not designed with the same capabilities there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2015 04:30 AM
Hi Krishna,
Please find the code below. I have added a setTimeout function which will wait for 1000ms for the filterstring to set and then populate the right slushbucket. Hope it helps
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var collectorName = '';
var filterString = '';
if (newValue != '') {
//Apply a filter to the list collector variable
collectorName = 'lol';
filterString = 'assigned_to=' + newValue;
alert("in onchange" +filterString );
// Gets the right column of the List Collector
var rightBucket2 = gel(collectorName + '_select_1');
// Loops through all the selected entries and remove them
while (rightBucket2.firstChild) {
if (rightBucket2.firstChild != null && rightBucket2.firstChild != '') {
rightBucket2.removeChild(rightBucket2.firstChild);
}
}
//Find the filter elements
var fil = gel('ep');
//Hide the filter elements
// 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
eval(collectorName + 'g_filter.reset()');
eval(collectorName + 'g_filter.setQuery("' + filterString + '")');
eval(collectorName + 'acRequest(null)');
setTimeout(setCollectorFilter, 1000);
}
}
function setCollectorFilter() {
var collectorName = '';
collectorName = 'lol';
//Name of variable to move options from
var leftBucket = gel(collectorName + '_select_0');
var rightBucket = gel(collectorName + '_select_1');
var selectedOptions = leftBucket.options;
alert("selectedOptions:"+selectedOptions.length);
//Get an array of all option IDs to move
var selectedIDs = new Array();
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, leftBucket, rightBucket, '--None--');
//Sort the resultant options in the left bucket
sortSelect(rightBucket);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2015 07:59 AM
Hi Gladcy,
Thanks
setTimeout approach is working..! But my filter query contains a large number of data, which is taking more than 10k milliseconds to load them into left-bucket. So the issue happens again for large number of data.
So now I need to find-out some dynamic time setter, instead hardcoding like 10k.
setTimeout(setCollectorFilter, 10000);
So, I need to pause the process upto the data loaded into the left-bucket.
Is there any idea to achieve this ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2015 07:02 AM
Hi Krishna,
why dont you use the Response time that is shown on load of the catalog form. Before calling "setCollectorFilter" function, get the response browser time,then use that to dynamically set the timeout.
var x = document.getElementsByClassName("timing_span");
alert( x[0].innerHTML);
setTimeout(setCollectorFilter, 1000); //instead of 1000 you can use the value that comes in x[0]
Thanks,
Gladcy