Setting dropdown contents on programmatic row creation

Setting dropdown contents on programmatic row creation

How do I set the options for a child dropdown list in a subform row when I create the row based on a template from a parent row. I've tried a few methods, but it seems like the UI for the row just doesn't exist until the function exits.

e.g. 
  1. for each value in newitemsrequired
  2. {
  3.       newrow = booking.subrows();
  4.       newrow.parentcolumn = booking.parentdefault;
  5.       newrow.childcolumn = booking.childdefault;
  6.       newrow.childcolumn:ui.add(getChildValues(newrow.parentcolumn)); //This does not work as the UI hasn't been generated yet.
  7.       input.subrows.insert(newrow);
  8. }