- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 12:17 PM
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
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2023 11:39 AM - edited 04-12-2023 11:45 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 01:30 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 02:03 PM
Hi Duggi, thanks for the quick reply. How would I set the regular expression to look for the employee name?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 02:42 PM
you need to create a flow variable and pass it to the short description while creating an incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 01:54 PM
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);