Dynamically add subform recorda on Form A to Lookup on Form B

Dynamically add subform recorda on Form A to Lookup on Form B

Hi,

I have tried the following script to dynamically populate a Lookup on Form B with subform records on Form A. I see the IDs are fetched bu the ui.add does not work here:

sob = FormA[ID == fet.ID.toString()].subForm;
input.FormBLookup:ui.add(sob.ID.getall());

Could you please help with the script that can fetch records from a Subform on Form A and dynamically add those records to a Lookup on Form B?

Thank you