How to create child table and call in script

To create child tables in ERP Next forms, you must create a doctype with the child table box checked. Then, in the main form, create a field with the table type and name the child doctype name in the options.
Also, to apply scripts to the child table, you must do the following:
in Server Script

for item in doc.yourchildtablefield:
{access to all fields in table}

in Client Script

frappe.ui.form.on('Purchase Invoice', { // your mother doctype
	refresh(frm) {
		// your code here
	}
})
frappe.ui.form.on('Purchase Invoice Item', { //your childtable doctype
	refresh(frm) {
		// your code here
	}
})