About Email Alert condition

Hi,
we’d like to create a new Email Alert for reminding upcoming due date of Purchase Invoice. I have no problem for other fields except condition field.
My condition have to include ‘supplier_type==‘Utilities’’ because we just want to remind purchase invoice for this kind of supplier type, but supplier_type field is not in Purchase Invoice Doc (it’s in Supplier Doc). How can I write condition in this case? or I need create a custom field ‘supplier type’ in Purchase Invoice Doc first?
Any reply will be appreciated.

try frappe.db.get_value('Supplier', doc.supplier, 'supplier_type')=='Utilities'

since its Jinja, it should run.

@rmehta Thanks your reply.

I tried, but got this error:

File “/home/erpnext/frappe-bench/apps/frappe/frappe/email/doctype/email_alert/email_alert.py”, line 77, in evaluate_alert
if not eval(alert.condition, context):
File “”, line 1, in
NameError: name ‘frappe’ is not defined

I checked the code in email_alert.py, the following code is about alert condition:

context = {“doc”: doc, “nowdate”: nowdate}
if alert.condition:
if not eval(alert.condition, context):
return

Does it mean condition cannot be other things except doc or nowdate?

yeah,

Since this is user defined, we should be vary of it being a security issue…

@rmehta Thanks, now I already created supplier type custom field in Purchase Invoice Doc.