Parsing email subject to create Case under proper client Account
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 11:17 AM
Scenario:
- A certain solution sends emails to ourinstance with the subject line starting with "[X] - ..........."
- [X] represents a unique field each client Account in our 'customer_account' table has, so actual email subject examples are "COMPY123" or "ACCNT001" or "CLNT535".
-- "COMPY123' corresponds to the [X] field value on the client Account named "Company 123"
-- "ACCNT001" corresponds to the [X] field value on the client Account named "Account 001"
-- "CLNT525" corresponds to the [X] field value on the client Account named "Client 525"
Requirement:
Using Flow Designer , parse the "[X]" string from the start of the email subject line, and use that value to return the corresponding record on 'customer_account' table.
-- any recommendations on how to accomplish this?
Thanks for all input,
Pat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2023 02:05 PM
You can use Flow Designer to parse the inbound email using Inbound Email Flows. Once you create a Flow that is responsible for dealing with your email then you can use the 'Lookup Record' action in Flow Designer to find the Account you want on the customer_account table.
Before you can do that though you're going to want to create a new Flow Variable called 'Parsed Account Name' (the name isn't that important. Once you have created it, you can set the value of this Flow Variable to the following code that will grab the Account Name from your inbound email.
// emailSubject represents the value of the Subject of the email, you should have access to this via the Data Pills in Flow Designer.
var emailSubject = 'ACCOUNT123 - Email Subject Line';
// This will get the value before the '-' in your subject, notice there is space in front of the - to cater for that also. This code assumes that your subject line is always rigid
var accountName = emailSubject.substring(0, emailSubject.indexOf(' -'));
// Once you set accountName, return (rather than print) it from the script so it gets set to the value of your Flow Variable.
gs.print(accountName)
Now that you have set the value of the Flow Variable, you can use it in your 'Lookup Record' step, where you can search for the customer_account via the name value we store in our Flow Variable.
Let me know if you run into any issues getting this set up.