Flow Designer - Create Incident - Set LOCATION based on abbreviation in email subject

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-14-2025 12:55 PM
- I'm working on Flow in Workflow Studio.
- Trigger is inbound email
- The subject line of each email starts with a 3 letter abbreviation that represents a field office locations. The same 3 letter abbreviations are on the cmn_location table as the field "u_loc_abbreviation".
- I want the Flow to Create Incident Record and set the Location field to the cmn_location.name associated with the "u_loc_abbreviation" that gets scraped from the email Subject.
How do I do this efficiently?
Thanks,
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 04:52 AM
hi @Jon Epstein ,
you can do as follows
Create a flow add the trigger condition as Application > Inbound email
then add the appropriate conditions
then add create record action where you need to define the incident table to create to record ,where location needs to set based on email subject
while set the field value just try like below
example script:
var sub= fd_data.trigger.subject;
var patt= sub.split(' ')[0];
if(patt){
var locationRec = new GlideRecord("cmn_location");
locationRec.addQuery("u_location_abbreviation",patt);
locationRec.query();
if(locationRec.next()){
return locationRec.sys_id;
}
}
Thanks,
BK

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 01:26 PM
Bhavya - thank you so much for the reply.
Can you tell me what "patt" is doing? Is it looking for patterns that exist on cmn_location?
Do I need to somehow tell it that the pattern is just 3 letters, or does the script intuit this?
Thanks,
Jon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-15-2025 09:51 PM
Hi @Jon Epstein ,
line by line breakdown
var sub= fd_data.trigger.subject; this is will retrieve the subject line of the email
where as this line "var patt= sub.split(' ')[0];" will split the subject by space using split(' ') and create words of an array accesses the first word of an array
For example
subject ="Urgent server down"
then sub.split(' ') = ["Urgent ","server ","down"]
where patt will holds the first array value because of this code "sub.split(' ')[0];"
in this example it will be Urgent.
Thanks,
BK

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2025 06:37 AM
Ah. That is mostly good 😁
Our location (plant) 3-letter abbreviations are not always separated by a space, however. Sometimes they are the first the letters of a word, sometimes they are separated by hyphen/dash.
This may make this experiment impossible, since we don't have consistency.
Thanks again.
Jon