Child Table On Create Event

I’m trying to figure out how to populate a child table item as soon as it is created. I can’t seem to find a way to call a client or server side function that automatically populates a child upon creation.

I’ve tried the following options with poor results:

Does not do anything:
frappe.ui.form.on("Item Reorder", "onload", function(frm, cdt, cdn) { //Insert Code Here});
frappe.ui.form.on("Item Reorder", "refresh", function(frm, cdt, cdn) { //Insert Code Here});
frappe.ui.form.on("Item", "reorder_levels_add", function(frm, cdt, cdn) { //Insert Code Here});

Only runs once the form is closed:
frappe.ui.form.on("Item Reorder", "form_render", function(frm, cdt, cdn) { //Insert Code Here});

I’m not sure where to put server side code for onload for child tables, as putting it in the child table .py file doesn’t seem to work.

Any suggestions would be appreciated!

2 Likes

Here is what I found worked:

cur_frm.cscript.custom_reorder_levels_add = function(frm, cdt, cdn) {//Insert Code Here});

where reorder_levels is the name of the child table in the parent.

2 Likes