Client Script for Child Table Filter

Hi! Can someone help me with this?

For doctype: PCF Report, I need to filter child table with field name: ‘expense_details’ (Child Table Doctype is ‘PCV Table’).

Under expense_details child table, I need to filter fieldname ‘pcv_no’ which is a Link Field for Doctype ‘Petty Cash Voucher’. pcv_no selected should have filter (status: “Liquidated”) Can someone help me with my script? It’s not working :smiling_face_with_tear:

frappe.ui.form.on('PCF Report', {
	refresh(frm) {
		frappe.ui.form.on('PCF Report', {
		    onload: function(frm) {
                frm.set_query('pcv_no', 'expense_details', function(){
                    return {
                        "filters": {
                            status: 'Liquidated'
                        }
                    };        
                });
		    }
        });
	}
});

dear @mehmehly you gave onload inside refresh function…

frappe.ui.form.on('PCF Report', {
    onload: function(frm) {
        frm.set_query('pcv_no', 'expense_details', function() {
            return {
                "filters": {
                    status: 'Liquidated'
                }
            };        
        });
    },

});

2 Likes

Hi @mehmehly,

Adding @ErpnextRaja,

If you want to understand how the filter works in ERPNext, please refer to the documentation for guidance.

Thank You!

@NCP … Feeling great while seeing your comment… This what our Ancestors told us ---- Dont give Fish… Teach them how catch the Fish…Thanks…

1 Like

@ErpnextRaja :sweat_smile:

Works perfectly!! Thank you so much!!! :hugs:

I have been reading this as I was making the script but I can’t seem to make it work :sweat_smile: Thanks so much!