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

Jon Epstein
Giga Guru
  • 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

7 REPLIES 7

Bhavya11
Kilo Patron

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 

Bhavya11_0-1744717824237.png

 

while set the field value just try like below

Bhavya11_1-1744717897381.png

 

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

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

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

 

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