How to print custom fields in custom print formats using print format builder?

We want to print transport details and other Custom Document fields like VAT ID from doc type Customer in Sales Invoice and other print documents but are unable to add it from the field list in the left bar. Can these be added using custom html field, What code would we have to write in custom html to fetch these fields.

In custom HTML you can write like {{ frappe.db.get_value("Customer", doc.customer, "vat_id") }}

1 Like

I’ve tried this suggestion, but I get this error:
OperationalError: (1054, "Unknown column 'vat_id' in 'field list'")

Do you have Custom Field “vat_id” in Customer?

Hello, please could you help me with a similar problem? I made a custom field named “in” under the company doc.type. “in” means identification number for my company and I would like to add it via custom html in my print format. I tried to access it via {{ frappe.db.get_value(“Account”, doc.ccompany, “in”) }}, but without success. I don’t know the frappe db hooks. Thank you very much.