If condition not working in filter

I’m getting very strange behaviour in filter without condition filter is working fine but the moment I apply for filter then then whole filter function stop working
here is my code

frappe.ui.form.on('Lead', 'onload', function(frm) {
    frm.set_query('contact_detail', function() {
        console.log(frm);
        if (frm.doc.from_existing == 1) {
            return {
                'filters': {
                    'link_name': frm.doc.select_customer
                }
            };
        }
        
        return {};
    });
});

Can anyone help with this

Thank you

frappe.ui.form.on('Lead', 'onload', function(frm) {
    frm.set_query('contact_detail', function() {
        if (frm.doc.from_existing == 1 && frm.doc.select_customer) {
            return {
                'filters': {
                    'link_name': frm.doc.select_customer
                }
            };
        } else {
            // If no filter condition is met, return an empty filter object
            return {};
        }
    });
});

try this

1 Like

Yes it is working Thank you.