How to show filtered link data automatically in child table

Hiiii
I have a link field in child table and this link field filtered based on some criteria.
I need custom script to show the filleted data automatically in read only child table (on load parent doctype).

@dufani1

frappe.ui.form.on("Server Sheet", "onload", function(frm) {
 cur_frm.set_query("backup_strategy","backup_strategy_details",function() {
        return {
            "filters": {
                "parent_field_filter_field":  cur_frm.doc.fieldname
            }
        };
    });
});

Hope you will get idea.

thanks @bhavikpatel7023 I made the filtration but I need to insert the filtered data in child table automatically.
Please advise…

@dufani1

                var child = frm.add_child("items");	
				frappe.model.set_value(child.doctype,child.name,"item_code","New Item Name");
				frappe.model.set_value(child.doctype,child.name,"qty","New Item qty");	
				frm.refresh_field("items");

Dear @bhavikpatel7023 is “items” mean the name of child table in parent? And what is the “new item name”? Shall put script in loop with filter or not?
Thanks for your time…

Yes. child means child table field name in parent doctype.
“new item name” means value of item_code field. here i used reference of sales invoice and sales invoice item doctype reference.

1 Like