Trigger after refresh_field

Is there code triggered when a doc child table is completed programmatically?

My example is the Get Sales Orders button on the Production Plan which fetches the open sales orders using the code below. refresh_field does not appear to trigger any other user code so that I can fetch the SO PO number to a custom field. I’ve tried various standard form events.

	get_sales_orders: function(frm) {
		frappe.call({
			method: "get_open_sales_orders",
			doc: frm.doc,
			callback: function(r) {
				refresh_field("sales_orders");
			}
		});
	},

I’ve also tried making the custom field a dependant because of the refresh_field code below, but that doesn’t work either.

refresh_field(fname) {
	if (this.fields_dict[fname] && this.fields_dict[fname].refresh) {
		this.fields_dict[fname].refresh();
		this.layout.refresh_dependency();
		this.layout.refresh_sections();
	}
}

Here’s my final solution which monkey patches the table field refresh function. This also works if you fill in the sales order table manually.

frappe.ui.form.on('Production Plan', {
    setup(frm) {
        const sos = frm.get_field('sales_orders');
        // replace the refresh function
        sos.refresh_super = sos.refresh;
        sos.refresh = () => {
            sos.refresh_super();
            for (const row_name in sos.grid.grid_rows_by_docname) {
                frm.trigger('sales_order', 'Production Plan Sales Order', row_name);
            }
        }
    },
});

frappe.ui.form.on('Production Plan Sales Order', {
    sales_order(frm, cdt, cdn) {
        const row = locals[cdt][cdn];
        if (row.sales_order) {
            frappe.model.with_doc('Sales Order', row.sales_order, function () {
                const so = frappe.model.get_doc('Sales Order', row.sales_order);
                frappe.model.set_value(cdt, cdn, 'po_no', so.po_no);
            });
        }
    },
});