Email Alert on Cancel sales invoice by sales user

Hello Team,

I want to Create Email Alert If Sales user cancels the Sales invoice. When Sales user cancel the Sales invoice Sales manager gets emails Stating that
“This Sales Invoice is Cancelled by Sales user Name”
In Email Alert I didn’t find any condition to check the role of the person who is cancelling the invoice?

Can any one help me to Create This?

Have you checked Email Alerts ?

Yes I checked email alert. I saw condition doc.status==cancel and send alert on.
But my question is if sales user cancels the sales invoice sales manager should get email that this invoice cancelled by sales user. How we can identify roles in email alert.

Email by Role option is there

Yes That is for receipant. I can put Sales Manager there. But condition is that sales manager and sales user both have access to cancel the invoice. Email should sent to manager when sales user cancels the Invoice not when sales manager cancel the invoice.

use frappe.get_roles() to access login user roles.


doc.docstatus == 2 and 'Sales user' in frappe.get_roles()

I tried what you said,

Its giving me following error

The Condition ''Sales user' in frappe.get_roles()' is invalid

I think these conditions are not working in an email alert.