Correctly create new doc for child table

How do I correctly insert a new document into the database?

When using frappe.get_doc and just giving the DocType and the name-related field it skips fields like “creation”, “modified”, “owner”.

I tried adding a row to a child table like this and had to specify “parent”, “parentfield”, “parenttype” and the child table DocType. Isn’t there an easier way, just based on the parent DocType and the fieldname?

Same for getting child table values from a parent DocType with frappe.get_list. Needing to specify the child table DocType seems counterintuitive to me. So I guess there’s a way I can get these values by just using the parent DocType and the fieldname?

Hi @codeag! It would be best if you use dict values to insert into the table. No need to specify fileds like creation, modified, owner as it will automatically be populated. Just make sure to specify those which are mandatory. Please see below use case as a guide. Thanks!

1 Like