Custom Print Fromat - frappe.db.get_value

I am trying to fetch value of Passport Number in Print Format.

When I write Employee Id, I am getting Passport Number on Print Format.

<td colspan="2">{{ frappe.db.get_value("Employee", "HR-EMP-00001", "passport_number") }}</td>

But when I am doing this …

{% set empid = doc.employee %}
<td colspan="2">{{ frappe.db.get_value("Employee", "empid", "passport_number") }}</td>

OR this…

<td colspan="2">{{ frappe.db.get_value("Employee", "doc.employee", "passport_number") }}</td>

It’s showing nothing.

May I know what I am missing?

May be you can try with the following:

Thanks for reply, I tried but not working.

Hi @lyf,

Please check your field name.

Above code 100% worked.

{{ frappe.db.get_value("Employee", doc.employee, 'passport_number') }}

// OR

{{ frappe.db.get_value("Employee", {"name": doc.employee}, 'passport_number') }}

Thank You!

1 Like