Extracting Name from Incident 'Description'

JW22
Tera Contributor

Hi All,

 

We currently have a new inbound action that is creating incidents with employee details such as name, location, action date, etc. passed into the 'Description' field within the incident (see below). We've created a flow designer to extract the location into our 'Location' field, but I'm looking for any recommendations on how we could best extract the name and action date into the incident fields? Has anyone ever used a flow designer to extract something like this before? Or would a business rule work best? 

 

Thanks in advance!

 

 

 

Example of Description body:

 

Employee Details

--------------------------------------------------

Employee Name................: John Smith

 

When to Action:

Date.........................: 04/11/2023

 

--------------------------------------------------

Office Details

--------------------------------------------------

Office Location..............: California

1 ACCEPTED SOLUTION

Ian Mildon
Tera Guru

Here's a quick example of a script you can add directly to the Inbound Action to get the name from the email. On the target field, I used "name" as the example, so insert the relevant field there.

var extractName = email.body_text;
var getName = [];
getName = extractName.toString().split(": "); // split just before the name
var splVal = getName[1].split("\n"); // split at carrage return after name
current.name.setDisplayValue(splVal[0]); // value between the two splits

 

 

View solution in original post

9 REPLIES 9

Thanks Tony, this is helpful. Is this meant to be a business rule or through flow designer? Much appreciated!

This would be configured as is for a BR, but the basic syntax is the bsame and you would just have to map to flow input\output variables.

Ian Mildon
Tera Guru

Here's a quick example of a script you can add directly to the Inbound Action to get the name from the email. On the target field, I used "name" as the example, so insert the relevant field there.

var extractName = email.body_text;
var getName = [];
getName = extractName.toString().split(": "); // split just before the name
var splVal = getName[1].split("\n"); // split at carrage return after name
current.name.setDisplayValue(splVal[0]); // value between the two splits

 

 

JW22
Tera Contributor

Thanks Ian, I appreciate it. The challenge here unfortunately is that there's multiple colons throughout the template. 

If you are wanting additional values extracted that are after the first colon, just keep creating new "splits" and numbering them appropriately: 0 for what is in front of the split point and 1 for what is after the split point.

 

And just because I used the ":" as the split point, you could swap it for "Name...............: " to make it more unique.