How do you iterate (through code) the question choices of a select box variable?

dmullinax
Mega Guru

In our Service Center, we have a Select Box variable with hard-coded dates.
find_real_file.png

Here is the variable definition.  It is a Select Box with Question Choices.  That is where the dates are hard-coded.
find_real_file.png

We want to remove dates that are 35 days or less.  My idea is to set up a catalog client script, iterate through the question choices (like an array), convert each string to a date and compare with today's date.  If that date is equal to or less than 35 days, then I could remove that date such as this...

g_form.removeOption('field_name','choice_value');

What would be the code to iterate through the question choices of a Select Box variable?

1 ACCEPTED SOLUTION

Sasha Sobolev
Mega Guru

There's two options you can try that will potentially let you do it client side.

-Option 1

-Option 2

Otherwise, if that does NOT work, Option 3...you can always use GlideAjax to access a server script where you can query the "Question Choice" table, and return the list of values you could then loop thru and removeOption.

Let me know if that helps.

View solution in original post

8 REPLIES 8

dmullinax
Mega Guru

I got this to work.  I went with the Script Include, and was able to remove question choices in the catalog client script.

Hi,

Glad you got it figured out. GlideAjax is the better option compared to getReference anyway, so there's another win for it.

Take care! 🙂


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Can you please elaborate? 

 

dmullinax
Mega Guru

This was an old question on the forum, over a year ago.  This is already solved.  I set up the code using a script include, and pulled it in through Catalog Client Script.