add or remove item in glide_list (list collector) in catalog client script

jomonmathew
Tera Contributor
 
5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@jomonmathew 

what's the actual requirement and what script did you start with?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

 

On change of a field I need to add or remove list option values of another field. This is glide_list and it is linked to a table

OlaN
Giga Sage
Giga Sage

Hi,

Is there a question to this question? 🙂

Tushar
Kilo Sage
Kilo Sage

Hi @jomonmathew 

 

To add an item to a glide_list, you can use the addItem() method.

The addItem() method takes two parameters: the name of the glide_list and the value of the item to add.

For example, the following code adds the item "Server 1" to the glide_list named "servers":

function addServer(listName, serverName)

{

var list = g_list.get(listName);

list.addItem(serverName);

}

 

To remove an item from a glide_list, you can use the removeItem() method and you can also use the reset() method to clear all the items from a glide_list.

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar