Avoiding Duplicate Emails in Frappe Notifications for the Same Role

Learn how to prevent sending duplicate emails in Frappe notifications when multiple users share the same role.

 · 2 min read

Introduction In Frappe workflows, notifications are crucial for keeping users updated πŸ“². However, one common issue is that users in the same role often receive the same notification multiple times. This happens when notifications are triggered for roles rather than specific individuals. In this blog, I’ll share how to avoid sending duplicate emails to users who belong to the same role in Frappe πŸ”„.

The Problem: Duplicate Emails for the Same Role When using roles for sending notifications in Frappe, all users assigned to that role will receive the same notification. For example, if both the Leave Recommender and Leave Approver are in the same role, they will both get the same notification when a leave application is updated, even if they’re not involved at that particular stage πŸšΆβ€β™‚οΈ. This can lead to redundant emails and confusion βŒπŸ“§.

Solution: Use "Receiver by Document Field" To avoid sending notifications to everyone in the same role, we can use the Receiver by Document Field option. This allows us to target specific individuals for each stage of the workflow, based on the document field (e.g., the recommender or approver for leave applications), instead of using roles 🎯.

Steps to Set It Up

Create a Notification: Go to the Notification doctype and create a new notification for the Leave Application document πŸ“. Set the Condition: Choose when to send the notification (e.g., when the leave status is Approved βœ… or Rejected ❌). Define the Recipient: Instead of selecting a role, choose Receiver by Document Field and specify the field that holds the recipient's email (e.g., doc.recommenderemail for the leave recommender, doc.approveremail for the leave approver) βœ‰οΈ. Personalize the Email: Use Jinja templates to personalize the email with details like employee name, leave type, and dates πŸ“…. Enable System Notification (Optional): If you also want notifications within the Frappe interface, check the box for Send System Notification πŸ””. Why This Works By using Receiver by Document Field, you ensure that only the relevant individual (e.g., leave recommender or approver) is notified, even if they belong to the same role πŸ‘€. This eliminates the problem of duplicate emails sent to everyone in the role πŸ”‡.

Conclusion Sending notifications to everyone in the same role can result in unnecessary and redundant emails πŸ“©. By using the Receiver by Document Field option, you can target specific recipients and ensure that notifications are sent only to the relevant people in your workflow πŸ‘₯. This makes communication smoother and more efficient πŸ› οΈ.

Happy coding! πŸš€


No comments yet.

Add a comment
Ctrl+Enter to add comment