Dynamic Population of Subform Dropdown

Dynamic Population of Subform Dropdown

On the user input of a field in the main form, I want to auto create subform rows (based on records in another form) and populate a dropdown field in each based on a third form. I've been able to dynamically populate subform row dropdown fields on the manual addition of a row, I can't get it to work when either adding a subform record or looping over added subform records.

I am creating a custom document upload process and want the subform dropdown to be populated with document names defined in another form. I am creating subform rows based on records from another form, and on each subform row before inserting in to the subform, I tried clearing the dropdown and looping over the document names fetched from the document config form, then using ui.append() with each document name. This dropdown values didn't get cleared nor did the document names get populated; the default dropdown options were shown.

I also tried first inserting subform rows without populating the dropdown, then looping over the subform, clearing, and populating the document name dropdown like above.

For additional context, I can't use a lookup field because the document name needs to remain the same once the document is validated (a checkbox in the form which stamps the user and datetime), but the document name configurations need to be able to be updated. I also need to filter the dropdown based on user permissions as in the document config form, there are user permissions assigned to each document.