Subforms : Clearing and only showing matching results in drop downs (pick lists)

Subforms : Clearing and only showing matching results in drop downs (pick lists)

I have a script that creates rows in an attendance subform when a training course is selected. So that I can add an employee to multiple courses. It works great, however there is a drop down for each course containing a list of modules - this currently shows every module for every course. I have been able to use deluge to only show modules that are related to the selected course - but this does not work in a subform for me.

My Code :

  1. for each subRecord in input.attendee_subform
  2. {
  3.     ModuleIDs = ModuleForm [module_courselookup == subRecord.attendee_courselookup].ID.getAll();
  4.     clear subRecord.attendee_modulelookup;
  5.     subRecord.attendee_modulelookup:ui.add(ModuleIDs);
  6. }

Lines 4 and 5 do not change the attendee_modulelookup field at all.

if I use an alert to show me what is currently in the field then it returns the correct value so I know it's looking at the right field - it just doesn't alter the contents of it at all.

What am I getting wrong ?