FlexiRule Docs
Send Email on Sales Order Submission
A beginner tutorial on triggering an automated email when a Sales Order is submitted.
Tutorial: Send Email on Sales Order Submission#
In this tutorial, we will create an automation that sends a “Thank You” email to a customer as soon as their Sales Order is submitted.
Business Scenario#
Objective: Improve customer engagement by providing instant confirmation of their order. Prerequisites: A working Email Account configured in your ERPNext/Frappe site.
Step-by-Step Instructions#
1. Create a New Rule#
- Navigate to Rule List and click New.
- Rule Name: “Customer Submission Thank You”.
- Document Type: “Sales Order”.
- Trigger Event: “On Submit”.
- Click Save and then click Open Rule Builder.
2. Add a Notify Action#
- On the canvas, hover over the connection point of the Entry Action and click the + icon.
- Search for Notify and select it.
- Change the node label to “Send Thank You Email”.
3. Configure the Email#
- Click on the “Send Thank You Email” node to open the configuration panel.
- Mode: Select “Email”.
- Recipients: Enter
{{ doc.contact_email }}. This dynamically fetches the customer’s email from the Sales Order. - Subject:
Thank you for your order! {{ doc.name }}. - Message:
Hi {{ doc.customer }},<br><br> We've received your order <b>{{ doc.name }}</b> for a total of {{ doc.grand_total }}.<br> Our team is now processing it. - Attach PDF: Check this box to include the Sales Order printout.
4. Test the Rule#
- Click Test Run in the top bar.
- Select a recent “Submitted” Sales Order.
- Click Run Test.
- Review the Execution Trace to ensure the path is highlighted in green.
5. Activate#
- Close the Rule Builder.
- On the Rule document, toggle Enabled to Yes.
- Click Save.
Expected Result#
The next time any user submits a Sales Order, the customer will receive an email automatically.
Common Mistakes#
- Incorrect Field Name: Using
{{ doc.email }}instead of{{ doc.contact_email }}. Always use the field picker in the UI to ensure accuracy. - Email Account Not Set: If your site doesn’t have a default outgoing email account, the email will stay in the “Error” queue.
Was this page helpful?