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:
- How can I trigger an email using the “Medical Opinion Created” template when a document with the specified status is created?
- What would be the best way to pass the document context and session user information to the email template?
- Is there a recommended way to implement this with a Server Script in Frappe?
Any help or examples would be greatly appreciated!