How to Send Email to the user When a Document is Created with a Specific Status

Hello Frappe Community,

I’m working on a project where I need to send an email automatically when a new document is created with a specific status. Here’s what I’m trying to achieve:

  • Use Case: Whenever a new document is created with the status “Pending for Hospital Opinion,” I want to trigger an email to the session user’s email address.
  • Email Template: I’ve already created an email template called “Medical Opinion Created” in the Email Template doctype.
  • Preferred Approach: I would prefer to handle this logic on the server side using a Server Script, rather than a Client Script, for better reliability.

What I’ve Tried:

I initially considered using a Client Script, but it didn’t give me the results I was hoping for. I’m now looking to implement this using a Server Script but need some guidance on how to properly set it up.

Specific Questions:

  1. How can I trigger an email using the “Medical Opinion Created” template when a document with the specified status is created?
  2. What would be the best way to pass the document context and session user information to the email template?
  3. Is there a recommended way to implement this with a Server Script in Frappe?

Any help or examples would be greatly appreciated!

Please refer this Notifications

I hope help this.

I already tried Notifications :slight_smile:

it is not triggering any event i dont know why?

@Prathyusha Please change send alert on from save to new

1 Like

Not working i getting throttled in console

can you show me one document of treatment request doctype

1 Like

@Prathyusha check email queue

1 Like

Yaah, their is no recent reords created in Email Queue Doctype

@Prathyusha you got system notification or not

1 Like