Sub-form in CRM module could not be auto-populated via client script

Sub-form in CRM module could not be auto-populated via client script

I'm trying to auto-populate a sub-form in a module based on a picklist value via client script. When the picklist option is selected the first time, the sub-form is auto-populated with the correct data. But when the picklist option is changed, the sub-form doesn't have the correct data as the data already populated is not properly reset. Also, noticed that there is only a getValue function in client script and no setValue function to set the data in sub-form. Any input of the options/workaround available on this would be helpful.