Filter Sales Invoice by Customer Primary Contact

Hi All,
I am currently working on Sales Invoice on ERPNext and i would like to be able to filter sales invoices by the customer’s primary contact, Since Customers can bear the same names it would be a lot more efficient to filter sales invoices by the customer primary contact number and not the full name as it is now.
I have thought about adding the customer’s primary contact number as a field in the sales invoice doctype, fetch from customer contact and populate that field during sales invoice validation but implementing that way will not be efficient in the case where the customer changes their number, all previous entries will not be fetched.
I would really appreciate if anyone can share ideas or suggestions on how to implement this. Thank you

Do you mean the primary contact’s name or the primary contact’s mobile number?

If you really want to pursue the filtering base on the primary contact number then you need to make the field contact number into “Allow on submit”, then whenever there is a change in the customer’s number then add a script through a hook to update all the “primary contact number” field in Sales Invoice.

I mean the contact’s Primary mobile number

thanks a lot for your suggestion .

1 Like