Filtering through custom script not working in list view

Filtering logic does not work in listview inside Doctype for child table but when I expand the row and then it works correctly. My code for custom script is in below:

frappe.ui.form.on('Sales Invoice Item',  'item_code', function(frm,cdt,cdn) {
    var d = locals[cdt][cdn];
  frappe.call({
    method: "erpnext.stock.doctype.item.item.itemwise_uom",
    args:{item:d.item_code},
    callback: function(r) {
        console.log(r);
        const  uoms =[];
        uoms.pop();
        for (var i = 0;i<r.message.length;i++){
            uoms.push(r.message[i].uom);
        }
        console.log(uoms);
        frm.set_query('uom', 'items', function(doc, cdt, cdn) {
				return {
					filters: [
						    ['name','in', uoms]
					]
				    
				}

		});
        
        
    }
});
});

Hi @Ryan1,

Try it.

frappe.ui.form.on("Sales Invoice", {
    refresh: function(frm, cdt, cdn) {
        var d = locals[cdt][cdn];
        frappe.call({
            method: "erpnext.stock.doctype.item.item.itemwise_uom",
            args: {
                item:d.item_code
            },
            callback: function(r) {
                const  uoms =[];
                uoms.pop();
                for (var i = 0; i<r.message.length; i++) {
                    uoms.push(r.message[i].uom);
                }
                frm.set_query('uom', 'items', function(doc, cdt, cdn) {
                    return {
                        filters: [
                            ['name','in', uoms]
                        ]
                    };
                });
            }
        });
    }
});

Then reload and check it.

Thank You!

Thanks for your reply…but the code is not working. @NCP

I just shared the code, for example, not tested. and also check the GitHub post. maybe helpful for you.

ok any other filtering way for child table other then set_query?

Please check this.

I have made another solution…made the array global and using cur_frm in get_query to filter the needed uom on item_code change in child table. There’s always a solution (logic) though incompatibility in code. @NCP