0

I have an email to case set up in my org which creates cases with subject and description. Description is a long text area field which contains the email body which has like firstname, lastname, email, linkt To The Website. I am currently replacing all the newlines in the string along with using a substring to fetch the data like firstname, last name etc. But sometimes the substring that I am looking for is changing in the email. For example, I sometimes receive 'link To The Website' and the other times it is like 'Direct link'. So, my question is how do I dynamically identify these values so that I can update the case.

Here is my code.

@InvocableMethod(label='Case Data' description='Case Data')
public static List<List<String>> getData (List<FlowInputs> request) {
    
    List<List<String>> outputList = new List<List<String>>();
    
    List<String> emailTextList = request[0].emailText;
  
    String firstNameString = emailTextList[0].substringBetween('firstname : ','lastname');

    // Add string values into a list
    List<String> stringList = new List<String>{firstNameString};

    outputList.add(stringList);
    
    return outputList;
}

Any pointers are appreciated. Thank you

1 Answer 1

1

If you can, exploit the values in Case.SuppliedName to get first/last

From the doc

Web Company Company name provided by a customer who created a case from Web-to-Case or Email-to-Case. ApiName = SuppliedCompany

Web Email Email address provided by a customer who created a case from Web-to-Case or Email-to-Case. ApiName = SuppliedEmail

Web Name Customer’s name as provided by a customer who created a case from Web-to-Case or Email-to-Case. ApiName = SuppliedName

Web Phone Phone number provided by the customer who created a case from Web-to-Case or Email-to-Case. ApiName = SuppliedPhone

You can split apart the SuppliedName by space and take the first token to be the First Name and the remaining tokens to be Last Name. Cleverer algorithms exist to handle names like Billy Sue Briggs versus Joe van Gustav or Hannah de la Cruz

2
  • Thanks for the answer but then I was also wondering about how do I get 'link to the website' ? @cropredy
    – Cathy
    Feb 16, 2023 at 21:30
  • for that, you'll need to parse the Description field using apex regex support; I was trying to point out that some of the parsing can be avoided because the values are in the OOTB fields
    – cropredy
    Feb 16, 2023 at 22:59

You must log in to answer this question.

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