ERPNext Notification Control (Alerts)
Notification ControlA complete guide to staying informed about important business events in ERPNext using automatic email, SMS, and Slack notifications.
Staying on top of critical business events is essential for smooth operations. ERPNext's Notification Control (formerly known as Email Alerts) allows you to automate communication based on document changes.
Whether it's notifying a sales manager about a high-value order, alerting the warehouse team of a new delivery, or sending payment reminders to customers, Notification Control handles it all automatically.
1 # Example: High Value Order Alert 2 # Trigger: On Submit of Sales Order 3 # Condition: Grand Total > 10000 4
5 subject: High Value Order: {{ doc.name }} 6 recipients: 7 - role: Sales Manager 8 - email: ceo@example.com 9
10 message: | 11 A new high-value order has been submitted. 12 Customer: {{ doc.customer_name }} 13 Amount: {{ doc.grand_total }} 14
Understanding This Code
What It Does
Automatically sends emails, SMS, or Slack messages when specific events occur in the system (like creating, saving, or submitting a document).
When To Use
Use alerts to keep stakeholders informed about critical updates without manual intervention, such as approval requests, high-value transactions, or stock level warnings.
Prerequisites
- •System Manager role to configure.
- •Configured Email Account for sending emails.
- •Slack/SMS settings configured if using those channels.
Key Concepts
Important ideas to understand in this code
Triggers
Events that start the notification process. Common triggers include 'New' (document creation), 'Submit' (document finalization), 'Cancel', 'Save', or 'Value Change' (critical for security monitoring).
Learn moreConditions
Logic checks to determine if the alert should be sent. You can use simple field comparisons or complex Python/JavaScript expressions to target specific scenarios (e.g., Grand Total > 10000).
Learn moreRecipients
Who receives the message? Recipients can be dynamic (document owner, customer contact), fixed email addresses, or specific system Roles (e.g., Accounts Manager).
Step-by-Step Tutorial
Follow along to understand how this code works
Access Notification List
Navigate to the Notification list to manage your alerts. You can find this by searching for 'Notification' in the awesome bar.
Search: Notification ListCreate New Notification
Click 'Add Notification'. Enter a descriptive Subject. In the 'Document Type' field, select the document you want to monitor (e.g., Sales Order, Leave Application).
Subject: High Value Order Alert
Document Type: Sales OrderSet Trigger and Conditions
Choose when the alert sends (e.g., on 'Submit'). Add a condition if needed. For example, to alert only for orders above $5,000:
Send Alert On: Submit
Condition: doc.grand_total > 5000Configure Recipients
Define who gets the message. You can send to specific email fields (like `contact_email`) or to internal users by Role. You can also send to fixed email addresses.
Send To: Sales Manager (Role)
CC: ceo@example.com (Fixed)Design the Message
Draft your message content. You can use Jinja templating to include dynamic data from the document, such as the Customer Name or Grand Total.
Hello,
A new high-value order {{ doc.name }} from {{ doc.customer_name }} amounting to {{ doc.grand_total }} has been submitted.
Regards,
ERP SystemBeyond operational updates, Notifications are a powerful tool for Security and Audit trails. You can monitor sensitive changes in the system to ensure compliance and prevent unauthorized access.
Step-by-Step Tutorial
Follow along to understand how this code works
Monitor Sensitive Fields
Want to know if someone changes a User's Role Profile? Set a notification on the 'User' document triggered by 'Value Change' on the 'role_profile_name' field.
Document Type: User
Send Alert On: Value Change
Value Changed: role_profile_nameAlert on Permission Changes
Receive an immediate email if a 'Role Permission Manager' document is modified or deleted. This is crucial for maintaining system integrity.
Document Type: Custom DocPerm
Send Alert On: SaveRestricted Access Attempts
While you can't alert on 'view' attempts easily, you can alert if a user tries to 'Cancel' a key document. This serves as a warning for potentially destructive actions.
Document Type: Purchase Order
Send Alert On: Cancel
Condition: doc.status == 'Compromised'Common Issues & Solutions
Troubleshoot problems you might encounter