Skip to main content
I have cases in SF which we use to manage claims. I store the claim number eg. 123456789 on the case in a custom field.

What we are doing is creating a custom inbound email handler to try and assess incoming emails and find the correct case to assign them to. Is there any way to take a email subject and search the claim numbers i have in the subject, If it contains a claim number we should put the email onto that case.

Ie

Case: 009873

Claim Number: 123456789

Incoming email subject: "New Claim - More Information Needed Claim 123456789"

We would find the claim number in the subject and therefore match the email to the case.

Is there a way to do this search on subjects through an inbound email handler?
2 answers
  1. Aug 4, 2018, 3:49 AM
    Brad, You can use the Pattern and Matcher classes to match against a regular expression to find your claim number inside the subject field.  The following will return the first 9-digit number found in the 'subject' input string (or null, if no 9-digit number is found):

    <pre>

    String claimNumber = Pattern.compile('(\\d{9})').matcher(subject).group(1);

    </pre>