CodeCharge StudioYou previously added the necessary code that sends email notification to the assignee upon recording a new task in the system. We shall now implement similar functionality in After Update Event to notify the assignee when an existing task is updated and reassigned to someone.
String uid = Utils.getUserId(e.getPage());
if (! uid.equals(e.getRecord().getControl("user_id_assign_to").getFormattedValue()))
{
String from = (String)DBTools.dLookUp("email", "employees", "emp_id=" + DBTools.toSql(uid, JDBCConnection.INTEGER, "IntranetDB"), "IntranetDB");
String to = (String)DBTools.dLookUp("email", "employees", "emp_id=" +
DBTools.toSql(e.getRecord().getControl("user_id_assign_to").getFormattedValue(), JDBCConnection.INTEGER, "IntranetDB"), "IntranetDB");
String host = "mysmtphost.com";
String subject = "A task was assigned to you";
String body = "The following task was assigned to you:<br><br>"+
"Task ID:"+ e.getPage().getParameter("task_id") +
"<br><br>"+ e.getRecord().getControl("task_desc").getFormattedValue();
SimpleMailer.sendEmail(from, to, subject, body, true, host);
}
The main differences between the above code and that which was used in the After Insert event are as follows:
http://localhost:8080/TaskManager/tasks_maint.jsp?task_id=9Next: Test Email Delivery