Dynamically setting the list collector
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2017 08:10 AM
I am trying to dynamically set the list collector based on choicelists that are selected. So my initial thought was to use Gurus method to set the filter. The issue with this is they are not unique values. I ran a few tests with this and if i can get unique values only this will not work. I have a client script and glide ajax that returns a comma separated list of values I want to place into the left side slushbucket BUT addOptions doesnt work with the list collector. Has anyone implemented something like what I am describing?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2017 08:27 AM
Sean,
You can use this : https://www.servicenowguru.com/scripting/client-scripts-scripting/move-list-collector-options/
Also check this : Re: Pre-select one option in list collector
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2017 08:46 AM
I was also looking at this but I dont want to dynamically set the right bucket based on the left options i want to populate only the left slush bucket with the options based on the 5 other fields above selected. I am not sure how this helps can you elaborate ? I already have a client script that returns the values in a comma separated list can i leverage this in populating the left slush bucket options?
For example if I was populating a choice list I would get my ajax response and populate like so.... I need to convert this into clearing out the left slushbucket and populating the values specific for the answer returned
function popOptions(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
var actionArray = answer.split(',');
for(i=0;i<actionArray.length;i++){
g_form.addOption('db_role',actionArray[i],actionArray[i]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 06:38 AM
So i was able to get something working using the glide_list and this thred.
https://servicenowgems.com/2016/11/14/setting-value-on-catalog-glidelist/
I added lines 16-18 and the options added correctly ! GREAT! except when the onChange fires again it doesnt clear the options. So I added lines 9-13 the problem i am having now is that it wont add the options back correctly. It only adds one option to the list but it does clear the list very unusual!
function popOptions(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
var actionArray = answer.split(',');
for(i=0;i<actionArray.length;i++){
var ref = g_form.resolveNameMap('db_role');
$(ref + '_unlock').click();
g_form.clearValue('db_role');
g_form.clearOptions('select_0IO:ba8c351fdb31f200ae7efdb61d96190c');
$(ref + '_lock').click();
$(ref + '_unlock').click();
addGlideListChoice('select_0' + ref, actionArray[i], actionArray[i]);
$(ref + '_lock').click();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2017 07:51 AM
With a combination of the below 2 articles Iw as able to dynamically set the glide list based on my ajax callback AND clear the values when the onChange fired again returning new values into the glide_list
https://servicenowgems.com/2016/11/14/setting-value-on-catalog-glidelist/
https://servicenowgems.com/2016/11/22/clearing-values-on-catalog-glidelist/