The CreatorCon Call for Content is officially open! Get started here.

Iterate through options of dropdown

snexplorer
Tera Contributor

Hi everyone! I want to iterate through all the options in an existing dropdown/select box. I'm thinking I can do that using 

g_form.getControl() but the output of that looks like this:snexplorer_1-1725556295038.png

 

The options array is empty even though the select box variable has multiple question choices tied to it that I'm able to view and select on the form UI. In addition, calling g_form.getElement('request_type') returns undefined.

I'm not sure if I'm calling these methods wrong. Later in my code, I do set the value of the same dropdown element using g_form.setValue('request_type', value) and it does successfully update the dropdown with what I want so I am using the right field name. Does anyone know what I'm doing wrong here? Is my expectation for the output of getControl incorrect?

7 REPLIES 7

Did you manage to find out anyhting about this? I'm having the same problem

Screenshot 2025-02-24 at 15.40.00.png

 best regards

I ended up having to create a script include to query the question_choice table with the variable sys_id and the parameter. Then use a GlideAjax call in your client script to call this script include to ultimately grab all the options of the dropdown variable

Thanks very much for your reply. I almost thought that's what you came up with. I hoped there is a solution without making a trip to the server.
Best regards