4

I have a email-to-case which shared the Record type from other group. I need to itendify the cases which is specifically created for our team and populate the some field values.

for alternative solution, we can use email services

but Is there a way to identify the new case originated from which email to case?

Thanks in advance.

2 Answers 2

4

If you need/want a configuration only solution (no apex), you can do you this. Define a specific case origin for each of you E2C addresses, and set then on the emails as appropriate. For example "Email-Support" or "Email-Info". To prevent your users from accidently selecting these sources, create a validation rule that only allows your default case creator to use your special origins.

5

If you can differentiate the types of cases via which email address the email was sent to, you could query the EmailMessage object to figure this out.

Let's say the cases you're interested in are all sent to [email protected]. Then something like this in your case insert trigger should work:

Case theCase = Trigger.New[0];
EmailMessage msg = [select Id, ToAddress
                    from EmailMessage
                    where ParentId = :theCase.Id
                    limit 1][0];
if ( msg.ToAddress == '[email protected]' ) {
  updateFieldsForYourTeam(theCase);
}

You will need to make this code bulk safe, but hopefully it should give you an idea of where to start looking.

2
  • JLiljegren__c your answer is also useful, but now i prefer no apex approch now. Thanks :)
    – goodForce
    Oct 18, 2013 at 3:27
  • 1
    FYI, I've tried implementing something similar to this with a record triggered flow, triggered upon case creation. The first step in the flow was to get email message records related to the case, however it would not reliably find the email for every email-to-case created case. It would appear that the emails aren't immediately available on the case when it's created. Looks like a race condition with what happens first - the email actually being added, or the flow checking for the email.
    – Garywoo
    Nov 25, 2022 at 17:15

You must log in to answer this question.

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