How to manage choices in glide_list type field

SunilKumar_P
Giga Sage

Hi,

 

I have created a field of type 'glide_list' as users want to select multiple values in it and have added choices to this field. However, I am unable to add or remove options on this field based on other field value.

 

Any suggestions would be greatly appreciated.

 

Regards,

Sunil

1 ACCEPTED SOLUTION

Hey Sunil,

 

I did some testing on my own and I was able to get this to work (in contrast to my previous reply). This is a little experimental (and guesswork), so your millage may very. Try this in your onChange client script:

 

g_form.removeOption('choice.incident.<variable_name>', '<choice_value>');

 

Replace <variable_name> with the Column Name of your variable, and <choice_value> with your choice Value. If you are on a different table, try replacing incident with your table name (or inspect the HTML to see what is listed for that element).

 

Basically I inspected the HTML element for the Glide List field and saw that choice.incident was a prefix of the field name. Running g_form.RemoveOption() in my browser console successfully removed the option. See attached for examples.

 

Remember that you will need to use g_form.addOption() to re-add any options you removed client-side if needed.

Hope this helps! Let me know if you need an example of a client script.

View solution in original post

10 REPLIES 10

Ankur Bawiskar
Tera Patron
Tera Patron

@SunilKumar_P 

Since that glide list is referring to sys_choice, those are sysIds, so you will have to add reference qualifier to filter

add or remove option won't work there.

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar - Thanks for your response. There is no reference as you can see below.

 

SunilKumar_P_0-1746806272522.png

 

 

However, as this field type usually deals with sys_ids, let me try and get back to you.

@SunilKumar_P 

did you try what value you get when you use alert?

I haven't used glide list with choice

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi @Ankur Bawiskar , tried with sys_id and other possibilities as well but no luck. I'm not sure if there is a way to handle choices in glide_list.