function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
faceroy123faceroy123 

Email to Case: finding string within a text area

Hi,

 

We are using SFDC email to case.

Is there a way to search a text area (body of the email) for a unique number and populate this to a field within the case object?

 

The unique number always follows this format e.g FY554077

(2 letters followed by 6 numbers).

 

Many thanks

 

 

SamReadySamReady

You'll need to use a regular expression (string that is used to match another string) by using the Pattern and Matcher classes in Apex.

 

for example: 

 

String body = (your message body containing the #);

Pattern.compile('[A-Z]{2}\d{6}|[a-z]{2}\d{6}]'); //(for ex. this will grab BC849203 or bc948593)

String[] result = Pattern.split(body);

 

The result list will contain each substring of the String that matches this pattern.

You can learn about how to build a regex here: http://docs.oracle.com/javase/1.5.0/docs/api/index.html?java/util/regex/Pattern.html

And test a regex here: http://regexpal.com/

 

 

 

tommytxtommytx
@Faceroy
If you are not familiar enought with Regex to know where in the exixting Case Apex code to place this snippet, then include the complete Apex case code and we can help you locate the snippet position.
faceroy123faceroy123

Thanks,

 

Where do I put the field that I'm querying in this code?

The body of the email drops into a field called Description__c.

 

Thank you

 

 

mizael leemizael lee
🔸 GNU Bash (https://www.becaps.life/" target="_blank) - is an sh-compatible shell that incorporates useful features from the Korn shell and C shell.
🔸 Zshz (http://vkay.net" target="_blank) - is a shell designed for interactive use, although it is also a powerful scripting language.
🔸 tclsh (https://www.becaps.life/becaps" target="_blank) - is a very powerful cross-platform shell, suitable for a huge range of uses.
🔸 bash-it (https://allinswap.co/" target="_blank) - is a framework for using, developing and maintaining shell scripts and custom commands.
🔸 Oh My ZSH! (https://www.becaps.life/corporativo" target="_blank) - is the best framework for managing your Zsh configuration.
🔸 Oh My Fish (https://www.foxx99.com.br" target="_blank) - the Fishshell framework.
🔸 Starship (https://www.alterativepharma.com.br" target="_blank) - the cross-shell prompt written in Rust.
🔸 powerlevel10k (http://alterativepharma.com.br" target="_blank) - is a fast reimplementation of Powerlevel9k ZSH (https://www.vkay.net/" target="_blank) theme.
Stella SallesStella Salles
However, if you use, you can spend your budget better and more efficiently by setting specific goals (Goal Setting) in Google Analytics or other measurement tools, and monitoring KPIs: estudioweb.com.br (https://estudioweb.com.br/)