I have added a Custom Field to Customer called ‘Primary Contact No’ and added this field name to the search fields in the Customize Form.
However there was no result while searching a customer using primary contact no.
Any Clue on how to search a Customer using a Custom Field?
thanks
Akshay
@mehta_akshay
Goto Setup > Configuration > Customize Form
Select the Customer, and define the “search fields” separated by “,”
2 Likes
vrms
February 17, 2016, 10:47pm
4
And? Is it working like that or not?
@mehta_akshay , some link fields, are based in complex queries! For example the customer, is based in party_filters
and it override the standard behavior based on the configuration.
@max_morais_dmm , so is there a work around here? can we search a customer with a custom field value?
@mehta_akshay , do you need change the active filters, like this:
$.extend(erpnext.queries, {
user: function() {
return { query: "frappe.core.doctype.user.user.user_query" };
},
lead: function() {
return { query: "erpnext.controllers.queries.lead_query" };
},
customer: function() {
return { query: "erpnext.controllers.queries.customer_query" };
},
supplier: function() {
return { query: "erpnext.controllers.queries.supplier_query" };
},
item: function(filters) {
var args = { query: "erpnext.controllers.queries.item_query" };
if(filters) args["filters"] = filters;
return args;
name, lead_name
limit %(page_len)s offset %(start)s""".format(
**{"fields": ", ".join(fields), "key": searchfield, "mcond": get_match_cond(doctype)}
),
{"txt": "%%%s%%" % txt, "_txt": txt.replace("%", ""), "start": start, "page_len": page_len},
)
# searches for customer
@frappe.whitelist()
@frappe.validate_and_sanitize_search_inputs
def customer_query(doctype, txt, searchfield, start, page_len, filters, as_dict=False):
doctype = "Customer"
conditions = []
cust_master_name = frappe.defaults.get_user_default("cust_master_name")
fields = ["name"]
if cust_master_name != "Customer Name":
fields.append("customer_name")
2 Likes
ccfiel
August 11, 2016, 6:53am
9
@max_morais_dmm How do I change the active filters? Can I do this in hooks.py?
@ccfiel , I am unaware of how to change the active filters, however we can use the custom queries for link in custom script to search the customer by a field of our choice
ccfiel
August 11, 2016, 9:17am
11
@mehta_akshay Example the Customer Doctype which is a standard doctype fo ERPNext how can we change the search field?
@ccfiel do you need re-create the filter in your app and use a custom module route
2 Likes
@mehta_akshay
you can change the field name in
get_customer_list() in customer.py
and according to that, search result will work.
I experienced a similar issue and found a solution. I have included a link below for reference.
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 …