0

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

Email coming to [email protected] routes to abc queue

Email coming to [email protected] 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.

2
  • 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 [email protected], set Origin as "Email-abc"; if email comes to [email protected], set origin as "Email-def" (or whatever suits your business requirement).
    – Ayub
    Sep 25, 2019 at 0:43
  • We are going with that only.. Point 4 I mentioned in my question :) Sep 25, 2019 at 14:53

3 Answers 3

3

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.

2
  • 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, 2019 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. :) Sep 25, 2019 at 14:52
0

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

2
  • We are not looking for any app exchange product for this and as I explained in my question, using PB is not very efficient. Sep 25, 2019 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, 2019 at 15:09
0

I have done plenty of research onto this and finally got the basics. The 1st operation that salesforce performs on Email to case is to convert the email to a case. All Assignment rules will work on the case and not on the email so if you want to Apply Assignment Rule on the Email Body Text then you need to Apply it on Case Description as that is where all the email text go. Probelm Solved!Assignment Rules

1
  • Welcome to Salesforce Stack Exchange (SFSE)! Great first contribution, thank you. For clarification: Have you tested/implemented this to know that it works, or do think that it should hypothetically work? Please edit your answer to add that clarification. That will help future searchers to have a better idea as to expectations for this solution.
    – Moonpie
    Nov 11, 2021 at 18:14

You must log in to answer this question.

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