You need to sign in to do that
Don't have an account?
Sabrina Oliveira 3
Sending emails with open tasks to their respective owners
I created a class scheduled to run once a week to let task owners know which tasks are open for them.
I am trying to compose the body of the email only with the open tasks of that specific user. With what I have so far, I am composing the email with all open tasks for all users. How can I do this?
I am trying to compose the body of the email only with the open tasks of that specific user. With what I have so far, I am composing the email with all open tasks for all users. How can I do this?
public EmailTasksWeekly() { Map<Id, List<Task>> tasksByUser = new Map<Id, List<Task>>(); for(Task taskRecord: [SELECT OwnerId, Id, Status, Subject, What.Name, ActivityDate FROM Task WHERE IsClosed = false AND Owner.IsActive = true]) { List<Task> userTasks = tasksByUser.get(taskRecord.OwnerId); if(userTasks == null) { tasksByUser.put(taskRecord.OwnerId, userTasks = new List<Task>()); } userTasks.add(taskRecord); } tasks = [Select ID, OwnerId, Status, Subject, What.Name, ActivityDate FROM Task WHERE Status = 'Open' AND OwnerId = :tasksByUser.keySet()]; }
>> https://developer.salesforce.com/forums/?id=906F00000005KiXIAU
This link has a similar implementation that you can try checking once.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
All Answers
>> https://developer.salesforce.com/forums/?id=906F00000005KiXIAU
This link has a similar implementation that you can try checking once.
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
Hi,
Thank You