Filter contact based on Customer

Create a doctype with two fields:

  1. customer Link to Customer
  2. contact Link to Contact

when in js

frm.set_query("contact", function(frm, cdt, cdn) {
	var d =locals[cdt][cdn];
	return {
		filters: [
			["Dynamic Link", "link_doctype", "=", "Customer"],
			["Dynamic Link", "link_name", "=", d.customer],

This produce this error

OperationalError: (1052, "Column 'idx' in order clause is ambiguous"

similar to : Fetch phone number script no longer working (since v8?)

What is the proper way to simple filter Contacts based on Customer ?


frm.set_query("contact", function() {
	return {
		filters: {
			"customer": doc.customer

Hi, try this

frm.set_query("contact", function(){
            if(frm.doc.customer) {
                return {
                    query: "frappe.geo.doctype.address.address.address_query",
                    filters: { link_doctype: "Customer", link_name: frm.doc.customer }

@SwitsolAG I just want to note that your are using address but I will see if there is something similar for contact

sorry, I forgot to change
query: "",