How to Parse Email Body text using Inbound Email in flow designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
I have a requirement to auto submit a catalog item, based on the inbound email content. I have seen few links but seems they are all for plain text.
I get the data in below table format, need to retrieve those field values and map it to catalog variables and submit the catalog item.
Contract ID | 4566 |
Contract Name | Test |
Vendor | TestXYZ |
Can someone please assist.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @Biso_Boby ,
you need to create a flow designer like shown in screenshot and set the field value using dot walk to inbound action-
and you can parse the body content like this-
my requirement is to get the content from body that is inside in double quotes- for that i have written-
Thank you
Nawal Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
whatever you use inbound action or inbound flow, you will have to do string manipulation to get the content from HTML table
see these links and enhance your script as your table might be different.
Note: your script will only work when customer always replies in the same HTML table format
Get the values from HTML table from an email in a Inblund Action
How to parse "Employee Name" from Email Body Text via a Inbound Action to Caller field?
see this link for inbound flow parser for incoming email
Easiest way to Trigger Catalog Item Request via Inbound Email
also check this
Launch a #ServiceNow Catalog Item from Email via Flow Designer (LIKE A BOSS)
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi@Biso_Boby ,
You can parse table content from body text like this-
var body = email.body_html;
var pattern = /<tr>(.*?)<\/tr>/g;
var rows = body.match(pattern);
for (var i = 1; i < rows.length; i++) { // skip header row
var row = rows[i];
var cells = row.match(/<td>(.*?)<\/td>/g);
if (cells && cells.length >= 3) {
var name = cells[0].replace(/<\/?td>/g, '').trim();
var emailAddress = cells[1].replace(/<\/?td>/g, '').trim();
var phone = cells[2].replace(/<\/?td>/g, '').trim();
var user = new GlideRecord('sys_user');
user.initialize();
user.name = name;
user.email = emailAddress;
user.phone = phone;
user.insert();
}
}
If you found my response helpful, please mark it as helpful and accept it as the solution.
Thank you
Nawal Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Biso_Boby To be frank, email parsing is not a reliable option. If a user changes the format or adds extra words here and there, the logic can easily break. However, since ServiceNow has changed this feature, you can try the links shared by other members in the thread.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************