How to Filter Address Based on Selected Customer in Frappe

Hi All,

I’m trying to filter the Customer Address field based on the selected Customer, but the following code is not working as expected:

customer: function (frm) {
    frm.set_query('customer_address', () => {
        return {
            filters: {
                link_doctype: 'Customer',
                link_name: frm.doc.customer
            }
        };
    });
}

I want the Customer Address field to only show addresses related to the selected Customer.
What am I doing wrong, or is there a better way to achieve this?

Any help would be appreciated!

@Sanmugam try this

frappe.ui.form.on('Your Doctype', {
    customer: function(frm) {
        frm.set_query('customer_address', () => {
            return {
                query: 'frappe.contacts.doctype.address.address.address_query',
                filters: {
                    link_doctype: 'Customer',
                    link_name: frm.doc.customer
                }
            };
        });
    }
});