You need to sign in to do that
Don't have an account?
taskTrigger on Case with Assignment Rule
I have 1 assignment rule on Case that assigns user and send email.
Works great with no Triggers on Task or Case.
Then i add this taskTrigger (to Tasks) and the (Case) assignment still works, but not email is sent.
Yes, the assignment rule is to a valid user, email and template (as i said, it works with no trigger).
Any ideas?
trigger taskTrigger on Task (before insert) { Case c; for (Task t : Trigger.new) { if(t.WhatId != null){ String s = t.WhatId; if(s.startsWith('500') && t.Status == 'Completed'){ c = [Select Id,Actual_Response_Time__c from Case where Id = :t.WhatId]; if(c.Actual_Response_Time__c == null){ c.Actual_Response_Time__c = System.now(); update c; } } } } }
Something in this code is causing my Case assignment rule to not send an email, but it still assigns correctly.
All Answers
That sounds mighty fishy, because by the time your trigger is run, the case will have already been assigned, so they should not be related.
Did you look at the trace in a debug log (Setup->Monitoring->Debug Logs) to see if there's something obvious there?
Sure, i will move to bulk coding once i figure this out.
Nothing in the logs since 2008, so i dont think i can find a solution there.
I understand your logic, however i took a much more simple approach.
I tried it without the Trigger and it works fine.
I add the Trigger and the issue i descibed happens.
Remove the Trigger, works perfect.
Any ideas on how to isolate and resolve?
I really dont want to add workflow for this, i should be able to get the intended functionality just by adding the Template Name in the assignment rule.
thanks wolf, sure i can use workflow, but I should also be able to add a Trigger to a Task and still have the intended functionality from the Case assignment rule work. What if i was trying to accomplish something else.
thanks for your advice, i get what you are saying.
now, i just want to know why this wont work, even though i can accomplish it other ways as you suggested, and i appreciate.
wolf,
Turns out it was completely RELATED to my problem (and is best practice).
I removed the update dml and it started working.
thanks again, i have used your advice from other posts as well,
Dale