Edit custom print format and fetch data from other doctype

Hello Guys,

I am doing a print format with custom HTML, Where i need to customize customer billing address field in the sales invoice as my need.

So, Added a custom script there.







<!-- here i want fetch data from other doctype “Address” ----->

{%- for row in frappe.get_list(doctype=“Address”,
fields=[“address_line1”, “address_line2”],
filters={ “link_name”:doc.customer_address}) -%}




{% endfor %}

Addresss


{{ row.address_line1 }}

{% if row.address_line1 %} {{ row.address_line1 }} {% endif -%}. {% if row.address_line2 %}
{{ row.address_line2 }}. {% endif -%}

However, The address still shows Blank.Kindly help me out to fix this problem.

create a variable like this and assign the doctype u need
{% set c = frappe.get_doc(“Doctype name”, data) %}
like this u can fetch the data
{{ c.data }}
in the feild of the data an doctype name give your data and docctype name

@Shivam_Shukla this is simple code you can use

{{frappe.db.get_value(“Address”, doc.customer_address, “address_line1”) or ‘’}}

{{frappe.db.get_value(“Address”, doc.customer_address, “address_line2”) or ‘’}}

{{frappe.db.get_value(“Address”, doc.customer_address, “city”) or ‘’}}

{{frappe.db.get_value(“Address”, doc.customer_address, “state”) or ‘’}}-
{{frappe.db.get_value(“Address”, doc.customer_address, “pincode”) or ‘’}}
{{frappe.db.get_value(“Address”, doc.customer_address, “country”) or ‘’}}

1 Like