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

DUGGI
Giga Guru

1) Extract the employee name:

  • Add a new "Transform Data" action to your flow.
  • Select the "Description" field as the input data.
  • Use a regular expression to extract the employee name from the description field. For example, the regular expression Employee Name\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.: (.+) would match the employee name in the sample data you provided.
  • Map the output of the regular expression to the "Short Description" field of the incident record.

2) Extract the action date:

  • Add a new "Transform Data" action to your flow.
  • Select the "Description" field as the input data.
  • Use a regular expression to extract the action date from the description field. For example, the regular expression Date\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.\\.: (.+) would match the action date in the sample data you provided.
  • Map the output of the regular expression to a custom date field on the incident record.

 

JW22
Tera Contributor

Hi Duggi, thanks for the quick reply. How would I set the regular expression to look for the employee name? 

DUGGI_0-1681249244048.png

 

you need to create a flow variable and pass it to the short description while creating an incident

 

DUGGI_1-1681249328568.png

 

 

Tony Chatfield1
Kilo Patron

Hi, if you were able to access the source and tidy up\remove the unnecessary '................ 'formatting it would be a lot cleaner. As an alternative to the regex solution, you will be able to use substring() and indexOf() to extract your values and I think this makes your intentions clearer to future users\developers.

var test = current.short_description;
var indexStart = test.indexOf('Employee Name');
var indexSize =  test.indexOf(':', indexStart);
var indexEnd = test.indexOf('\n', indexStart);
var myString = test.substring(indexStart + (indexSize - indexStart), indexEnd).trim();
gs.info(myString);