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.
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. Login to start a new discussion Start a new discussion