Parse Email Address from Description Field

JW22
Tera Contributor

Hi All,

 

We're looking for a solution using a business rule (or flow?) to identify and parse an email address in a body of text in the Description field of a new case, and then copy that email address to the 'Requested For' field. Has anyone set-up anything similar? 

 

I started on the following business rule that could be an option, but I'm open to any suggestions that others may have. Thank you!

 

var sd = current.getValue('description');
var str = sd.match(/\Email address: +[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9_-]*[\s]+/g).toString();
var arr = str.split(':');
gs.print(arr[1].trim());
current.setDisplayValue('u_requested_for', arr[1].trim());
1 ACCEPTED SOLUTION

Amit Verma
Kilo Patron
Kilo Patron

Hi @JW22 

 

If I understood your requirement clearly, you want to set the Requested For user as per the email ID of the employee received in the email body. I think you can go ahead with a flow with trigger type as Inbound Email with specific filter conditions as per requirement. Inside the flow, you can make use of a flow variable to parse the email body and get the email ID. With the email ID, you can make use of Lookup Record Action to get the user record and use it to set the requested for field while creating the case.

 

AmitVerma_0-1736217101084.png

 

AmitVerma_1-1736217127185.png

 

AmitVerma_2-1736217276966.png

var emailBody = fd_data.trigger.inbound_email.body;
var employeeEmail = emailBody.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
return employeeEmail[0];

 

AmitVerma_3-1736217341607.png

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

View solution in original post

7 REPLIES 7

jcmings
Mega Sage

Curious to hear how the record is being created. Is this a record producer/catalog item? Also curious to hear the business case.

JW22
Tera Contributor

Thanks for the reply, the case record is currently being created through an inbound email action from a generic mailbox. Within this email body (being written to the Description field), we want to isolate an employee's email address, and then copy it to the 'Requested For' field. 

You should be able to access the sender's email directly without having to write it to description. Try using email.origemail to grab this. Here's a doc from ServiceNow with more info.

JW22
Tera Contributor

Unfortunately the sender and the employee identified in the email body are different.