Check for existence of a field (Jinja)

How can I check for existence of a field? The link field between a sale order and an invoice only exists if you use “Get items from” to the invoice from the sales order. Therefore, when making a custom invoice print format you have to check for existence of this link field, when I want to show the customers PO reference (field: po_no)
I have tried: {% if frappe.db.exists(“Sales Order”, row.sales_order) %} …but it is not working.
I appreciate your help.

{% if row.task %}
{% set task = frappe.get_doc(‘Task’, row.task)%}
{%set subject=task.subject%}
{% else %}
{% set subject=’’%}
{% endif %}
{{subject}} --result