I am trying to route emails to specific queues based on Incoming Email ID example

Email coming to abc@xyz.com routes to abc queue

Email coming to def@xyz.com routes to def queue 

and so on

When I send an email to the email address, it catches the TO address in the Email related list on Case correctly but assignment rules perhaps fires a bit earlier before email is added to the email related list -- since my case is getting assigned to default user and not to the queue.

Is there anything I can do so that assignment rule is fired a bit later

I know other options mentioned on the forum and my own research like

  1. Creating a process builder to dummy update every new case record so that assignment rule fires 
(Not efficient way I believe)
  2. Using a flow for the same (Not efficient)
  3. Before Insert trigger for case (Best option if using customization)
  4. Using Case Origin = Email Routing Address and using it in assignment rule. 
(Crude option since picklist will have so many email values)

I even tried capturing "Email Message: To Address" on case custom field and it gets the value but still assignment rule ignores it when i use the field in rule criteria. Again perhaps because when rule is run, its value is blank and gets populated a bit later.

Please advise.

  • 1
    In such Cases, I use Case origin field because I can set its value in e2c setting and since this field is on case we use in assignment rule. For example, if email comes to abc@xyz.com, set Origin as "Email-abc"; if email comes to def@xyz.com, set origin as "Email-def" (or whatever suits your business requirement). – Ayub Sep 25 '19 at 0:43
  • We are going with that only.. Point 4 I mentioned in my question :) – Pankaj Gupta Sep 25 '19 at 14:53

Pankaj, You are right about order of operations. I'm not sure of a an easy method without resorting to Apex.

This could also be accomplished using a custom InboundEmailHandler class (developer doc), or possibly through rules on your email server. If you have access/control at the email server, you could append the "To address" in the email's Subject, which becomes the Case's Subject, and can be used in an assignment rule.

  • 1
    The route we took previously was a custom email handler to parse out orgwide email addresses from the "to" and or "cc" fields, once the emails were parsed out and we knew the destination we match the email up to custom meta-data so that we can do things like assign to specific queues or handle error messages, etc. – gNerb Sep 24 '19 at 22:01
  • 1
    Thanks for details on apex. We have for now decided to go with adding values to Case Origin Picklist and use it to route cases. Business wants to hold customization as long as they can. :) – Pankaj Gupta Sep 25 '19 at 14:52

Here's another approach

As the Case assignment rules are run before the EmailMessage object is saved....

Create a new custom checkbox field on Case called Is_pending_Reassignment__c (defaults to true)

  1. Add a Case Assignment Rule at the top that routes all Cases where Case.origin = Email AND Case.Is_pending_Reassignment__c = true to a PendingReassignment Queue
  2. Write a PB on EmailMessage that does three things:

Thus, the Case will get reassigned, the first rule is skipped and your normal Case Assignment rules are applied using logic that can exploit values on Case

A variation of this (illustration is for Lead but Case applies as well) can be found on Automation Champion

  • We are not looking for any app exchange product for this and as I explained in my question, using PB is not very efficient. – Pankaj Gupta Sep 25 '19 at 14:54
  • So you want an apex solution? It will mirror what I proposed: two passes through the assignment rules. Trigger instead of PB – cropredy Sep 25 '19 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.