ERPNext Conference 2019* ERPNext.com Blog

Fetch customer address in a docype

customization
erpnext

#1

Can someone please help me in fetching particular customer’s addess(address line 1, city, state, country and postal code) in another doctype’s print format.
I am adding customer link field in my doctype.
Thanks in Advance.


#2

@Saditi try this:

{{ frappe.db.get_value([DocType], filters={"x":"y"}, fieldname= Column name) }}

{{ frappe.db.get_value("Material Request",filters={'material_request_type':'Purchase'},fieldname='name') }}

#3

Thanks for replying, @ROHAN_JAIN1
Sorry for checking your reply late, but can you explain this syntax(child doctype, parent doctype, current doctype).


#4

{{ frappe.db.get_value("Material Request",filters={'material_request_type':'Purchase'},fieldname='name') }}

Material Request is Doctype, this script should be written in parent doctype custom print format


#5

@ROHAN_JAIN1
I have created custom doctype “Test” with custom print format and I am giving a link field to select a customer. So now I want to fetch that particular customer’s address from doctype “Address” in Test doctype.


#6

@Saditi
{{ frappe.db.get_value("Address",filters={'address_title':doc.customer_name},fieldname=['address_line1','address_line2','city','state','pincode'],as_dict=true)}}


#7

Thanks @ROHAN_JAIN1,
I will try and get back to you on this.