How to pull a reference number from an email body text for inbound email in flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 03:39 AM
Hi
I am trying to use inbound email in flow designer to update an existing RITM ref number.
The ref number is in the email body and will show like this on the inbound email
Version Visit Email Address: RITM1234567@new,employee.com
The ref number will be different each time but the @new.employee.com will be the same
I need a script to split the ref number on the email body and check if that ref number exists and if so then to update the ref with the email.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 03:46 AM
Hi,
I guess you will have to script a bit to get the needed data.
Basically, store the emailtext in a variable, split the data into an array using newline as a separator.
Loop through the array (each line of text in the mail).
If the identifier is found, extract the RITM number.
Return the RITM number to the Flow.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 04:05 AM
Hi
I am not good with scripting, do you have anything i could try please?
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2023 11:00 AM
I've made a simple example script for you to start with.
And attached a simple flow image that shows how it can be used.
var emailText = fd_data.trigger.inbound_email.body.toString(); // store the entire email body into a variable
var ritmNumber = '';
var identifier = '@new,employee.com.'; // your identifier to find the correct line in the text, change if needed
var arrayText = emailText.split('\n'); // split the email text into an array using newline as separator
for (var i=0; i<arrayText .length; i++){
if (arrayText [i].indexOf(identifier) != -1){ // if we found your identifier
ritmNumber = arrayText[i];
ritmNumber = ritmNumber.replace(identifier, ''); // remove the identifier text from the string
ritmNumber = ritmNumber.replace('Version Visit Email Address:', ''); // remove the starting text in the string
ritmNumber = ritmNumber.trim(); // remove remaining whitespaces
break;
}
}
return ritmNumber;
Flow overview:
Flow step 1 in detail: