Getting a list variable to work in a script

Getting a list variable to work in a script


Hello,

Was wondering if you could help me with how to set a variable derived from a list as a suffix on a field name, Below is my 1st attempt at scripting.

Basically I want to do the same If and else statement for three form fields. I thought I could use Custom function but it does not like the 'Clear' item in the if statement.

Child_option_1
Child_option_2
Child_option_3

//// Script

  1. optionno = {"1", "2", "3"};
  2. for each Option_var in optionno
  3. {

  4.           if (count(Testform2[Parent_option == input.Product_Parent])  ==  0)
  5.                     {
  6.                         set optionNo = "Child_option_"+Option_var;
  7.                         clear optionNo;
  8.                     }
  9.                     else
  10.                     {
  11.                         set optionNo = "Child_option_"+Option_var;
  12.                         rec1  =  Testform2  [Parent_option == input.Parent_option] sort by  Child_option ;
  13.                         optionNo:ui.add(rec1.Child_option.getall());
  14.                     }
  15. }


I have given you access to my application Test01 which is basic application that I use to teach myself deluge script syntax.

Thanks in advance for your help.