You need to sign in to do that
Don't have an account?
Salesforce keeps reassigning Case owner from Email2Case
Hi,
I have created a trigger on he EmailMessage object that checks the address an Email was sent to and uses that Address to match it with the Users in Salesforce that have their own personal address (a custom field) entered. When a match is found it will change the ownership of the Case that was created by Email2Case to that particular person.
The case is created, assignment rules change ownership to a queue. Then my after trigger changes ownership again to the correct person.
Now here is the strange part. After this Salesforce changes ownership of the Case to the Standard Case owner User that is specified under Case support settings if Salesforce was unable to assign a case.
Does anyone know why this happens? Why does this rule apply? If i look at a case history it first has an owner from the assignment rules, then an owner from my trigger and still Salesforce seems to think it was unable to assign an owner to the case and changes it back to the default setting..
If anyone is interested, we fixed it by executing our code in a class with the @future annotation.
All Answers
Working on a hunch here, reckon this is assignment rules kicking in
Here's a bit about assignment rules
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_database_dmloptions.htm
I would try using a DMLOption in your update to prevent the default rule firing, i.e. something like this
I am using an after trigger on the EmailMessage object.
I added a check on the Case before trigger that set up the options like you specified when a case will be created from email2case. It still just reassigns ownership after everything is done
I also tried creating a dummy owner and add it to the before case trigger. That way it would have an owner, the default owner thing wouldn't pop up and I just overwrite the owner with the after trigger. Still, salesforce puts the default owner on the case -_-
http://boards.developerforce.com/t5/Apex-Code-Development/using-DMLOptions-in-trigger-not-working/m-p/261601#M45584
Tried that one as well, doesn't work
If anyone is interested, we fixed it by executing our code in a class with the @future annotation.
Could you please explain how it is achieved using Future annotation
Create a Case Assignment rule with a rule that always triggers (for instance the Case OwnerID not empty
And check the field: Do Not Reassign Owner
http://how2salesforce.blogspot.nl/2017/07/leadcase-assignment-rules-reassigns.html