You need to sign in to do that
Don't have an account?

cross object trigger
I would like to write a trigger when task is completed and the case (a field) associated to the task send an email, trigger doesnt work when i add a field from a different object different from task:
.customer_Service_Agent__c is on case not task
.customer_Service_Agent__c is on case not task
trigger Notify_task_creator on task (after update) { task t=[select CreatedBy.email, id, CreatedByid, CreatedBy.name, LastModifiedByid, LastModifiedBy.name, Subject from task where id=:trigger.newMap.keySet()]; for (task o : Trigger.new) { if((o.Status=='Completed' ) && (o.CreatedByid != o.LastModifiedByid) && (o.CreatedByid != o.customer_Service_Agent__c)){ MailerUtils.sendMail('<html><body>Hi ' + t.CreatedBy.name +', <br><br>' + t.LastModifiedBy.name + ' has completed the task: "' + t.Subject + '" <br><br>Click on this link for more information:</body></html>' + '\n' + 'https://p2-1147--Full.cs11.cloudforce.com/'+o.Id); } } }
All Answers
Also why are you querying for the task using .keySet, and then looping through trigger.new? you only need to do one or the other.