Notifications. Condition syntax. Using db functions


I’m trying to set a condition in notifications, using frappe.db.count function, but is not working, the notification can’t be saved, because condition is not validated.

The use case is determine if the actual record has related records linked to it in other doctypes to avoid send notification.

I thought that any expression that works on python, including framework functions, would be used in conditions … but seems it is not working that way, at least in notification doctype.

Anyone solved something like this?

Thanks in advance.

It looks like the issue is right here:

When building the safe_eval local context, the notification doc requests only frappe.utils methods. I see why they’d want to block write requests in a condition eval, but there are many use cases for for db read methods. There may be other reasons that it was done this way, but in any case it should be possible to change.

1 Like

Thanks, @peterg . Very useful.