Brad Tilton
ServiceNow Employee

Did you know that in Helsinki you can force a list collector variable to display as a glide list field by adding an attribute to the variable definition record? Neither did I until this morning and I wanted to share that out.

Why would you even want to do this? Well, list collectors are nice and basically allow you a multiple select reference field where you have all the records on a table on the left and you can move one or more values to the right.

9bbb8924ee.png

It's a nice feature, but list collector variables take up a ton of space, load more slowly than other variable types, and require some DOM manipulation in order to set the values on the right hand side. It's a pretty common ask to use the list field type (like the watch list on the task table) as it takes up less room, loads more quickly, and can be manipulated using the g_form.setValue() method. It's been possible to do this in the past, but requires a ui macro and hasn't worked all that well for me.

In Helsinki, I can add the glide_list attribute to the variable definition and then that list collector magically turns into a glide list.

4fc2c09e20.png

Shows this:

9fdbbb2ea7.png

Expanded:

9d89822602.png

I think there is definitely a place for both of these types of renderings, but it's nice to have an easy way to toggle between the two.

Types of variables

23 Comments
hartr
Giga Contributor

Does anyone know how to clear the values selected ? g_form.clearValue('xxxxxx') doesn't seem to work if using the glide_list attribute, nor does rightside/leftside script..


Not applicable

Leave it blank, g_form.setValue('field', '');


hartr
Giga Contributor

Tried that - doesn't work either..


amlanpal
Kilo Sage

Hi Brad,



I have converted one List Collector type variable to Glide List type by using the variable attributes as glide_list. After which I'm facing a typical problem with one onChange catalog client script. It is checking if among the selected values 'value_1' remains, another variable   named 'other' is set as mandatory. It is working fine for the List Collector type variable before I changed it to Glide List.


For Glide List type variable it is checking whether 'value_1' is selected or not and selection on 'value_1' it is making the variable 'other' mandatory. But whenever I'm removing the value it is not checking and the code fails.


I have debugged and found that the whenever we remove any selected value in the Glide List type variable, the value is not changing for the variable (newValue concept doesn't apply at this stage). The value does change only when we add any value making newValue some sense. Is there any solution/work around available for this? Please find the code below:



function onChange(control, oldValue, newValue, isLoading) {


      if (newValue == '') {


              g_form.setMandatory('other', false);


              return;


      }


     


      if (isLoading || newValue != ''){


              if (newValue.toString().indexOf("276d83b76f0db200f9ac52b10b3ee475") >-1) {   //Sys id of 'value_1' is passed here.


                      g_form.setMandatory('other', true);


              }


              else


                      {


                      g_form.setMandatory('other', false);   //For Glide List variable the code does not run this else portion at all.


              }


             


      }


}


amlanpal
Kilo Sage

Hi b-rad,



Could you able to look at this issue? For glide_list type variable, adding new value in the list is considered as newValue in onChange Catalog Client Script. Whereas removing any selected value doesn't.


Please let me know if you have any suggestion and information on the same.


Brad Tilton
ServiceNow Employee

I'm not aware of a workaround, so you might want to open a hi ticket.


amlanpal
Kilo Sage

Thanks for your response Brad!


Inactive_Use160
Mega Contributor

Hi Brad,



I'm trying to set the value of a glide_list variable through an onChange catalog script, but tipical g_form.setvalue doesn't work, would you have any idea on how to set it ?



Thanks



Agathe


Brad Tilton
ServiceNow Employee

Have you tried setting the value as a comma separated list of sys_ids?


Inactive_Use160
Mega Contributor

I tried with the comma separated list, using a single fix sys id (just as a try) and going through a loop to set the list from existing value for this field...nothing worked...:/