ERPNext.com Frappe Cloud Support Partners Foundation Frappe School

Applying filter in childtable

Hello all,

I created a doctype “Countsheet Template”… Now in my doctype there is a childtable “Outlet Prep”
And there is another doctype “Item”…In that there is a child table unit of measure…so from that i have to fetch data in childtable “outlet prep”

this is my py code:

@frappe.whitelist()
def get_uom_conversion(item_code):
item = frappe.db.sql("""
select uom_conversion_detail.uom, item.item_code
from tabUOM Conversion Detail uom_conversion_detail join tabItem item on uom_conversion_detail.parent=item.name where item.item_code=%s
and item.docstatus=0 “”", item_code, as_dict = 1)

return item if item else None

This is my Js code:

frappe.ui.form.on(‘Countsheet Template’, {

refresh: function (frm) {
    console.log('refersh function..................')
    frm.fields_dict['outlet_prep'].grid.get_field('broken_uom').get_query = function (frm, cdt, cdn) {
        var child = locals[cdt][cdn];
        
        if (child.item_code) {
            var uom_list = [];
            console.log('child table item code has value')
            frappe.call({
                method: "dsr.dsr.doctype.countsheet_template.countsheet_template.get_uom_conversion",
                args: {
                    'item_code': child.item_code
                },
                callback: function (data) {
                    
                    for (var i = 0; i < data.message.length; i++) {
                        console.log(data.message[i].uom)
                        uom_list[i] = data.message[i].uom;
                    }
                }
            })
            console.log(uom_list);
            
            return {
                filters: [
                    ['uom_name', 'in', uom_list]
                    
                ]
            }
        }
        frm.refresh_field("outlet_prep");

    }
}

this is from where i want data:

this is what i am getting:

please tell me why i am not getting the list though filter is applied correctly…
It’s urgent!!

Did you examine this ?

1 Like

@TurkerTunali but that is not for child table…right??

Sorry ?