Insert into child table throw api

how to insert into specific child table throw api using python ,
note : i have the parent name

no one know how to do this !!

Hi,
You can use frappe.get_doc to get the parent doc, and then you can use the .append method to add to your child table by passing the child table field name and then the value of the fields like so:

program = frappe.get_doc('Program', entry)
	program.append('courses', {
		'course': course,
		'course_name': course,
		'mandatory': mandatory
	})
 program.save()

check this example here:

Hope this helps

2 Likes
parent = frappe.get_doc('Sales Order', 'SO-00002')
parent.append("items", {
    'company': 'company_name',
    'item_code': 'item_code',
    'item_name': 'item_name'
})
parent.save()
frappe.db.commit()
1 Like