2

I have a scenario where Case Owner is changed only using Apex code, rather than through assignment rules + default owner. We've been able to make it work for a couple of different Case creation scenarios.

However, when using email-to-case (at least on-demand) the assignment rules + default owner are applied.As this happens after the Apex code we use (an after insert trigger), the Case Owner gets overridden.

We have implemented a workaround, using a "dummy" assignment rule. It works, but it's not a very nice solution. We have some other ideas, but they may require more effort.

We'd like to understand our options. Is it possible to prevent the assignment rules + default owner from being applied in the first place when using email-to-case?

2 Answers 2

4

I've solved this as follows

  • Recognize that triggers run before assignment rules and E2C will run assignment rules.
  • In before insert trigger, set custom field Bypass_Assignment_Rules__c to true for those use cases where assignment rules should be bypassed.
  • Create assignment rule (at position 1) that takes any Case with Bypass_Assignment_Rules__c = true and assign to a "in-transit queue"
  • This change in ownership will re-execute your triggers that can detect ownerId = inTransitQueueId and then do the assignment as you desire while also turning Bypass_Assignment_Rules__cto false.
1
  • Thank you for the quick anwer! This makes a lot of sense, so I have what I need now. Jan 25, 2017 at 8:25
0

Background

For Email To Case the assignment rule will fire after the triggers. So if we update the case owner in the insert trigger , then it executes the assignment rule and the case owner will be based on the Assignment rule entry not the one updated in the trigger.

How I solved the problem!!!!

  1. In the after insert trigger accumulated all the ids that need the
    owner update.
    Passed those ids to a future method.
    In the future method done the necessary check and assigned the new case owner as per my requirement.

It works fine for me :)

I tried many other ways to tackle the problem, but it is future method that helps to solve the problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .