Customer as link field: searching fields and the shape

Hello;

What is the story of using Customer as link field?
I selected in the customize form the searching field to be based on the phone field but when I do search (while I am selecting the customer), I do not find any customer. This situation is not existed with Customer link field in sales order and sales invoice but when I add Customer as link field in any other doctype, I do not see the search fields has any value (also I do not see any of these fields in the drop down). So why?

Below are images:
This is the customize form for the customer and it shows what the searching field:

At the Sales Order, I can search on the customer based on the phone, and I can see the phone in the drop down, but I am surprised why it is showing me the customer group and territory in the drop down list as I did not select these fields in the searching fields.

At the Timesheet, I added the customer as custom field of type link but I can not do search based on the phone and the phone is not appear in the drop down list:

Note: At the Selling Settings, I selected the Customer Naming to be by Customer Name.

This is an important issue: how to be resolved? I need to be able to search based on the Phone field (or any customize field that I can added), and I need to see the Phone field in the drop down list. What is the solution in this case?

Regards
Bilal

OK, I found the solution :slight_smile:
The problem is resolved by the below script that need to be placed at onload:

            frm.set_query('customer', function(doc) {
                    return {
                            query: "erpnext.controllers.queries.customer_query"
                    };
            });

Regards
Bilal

3 Likes