How to access data from a table in inbound action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 04:40 AM
I want to pick values from a multirow table.
SBU Head Email ID | XYZ |
SBU | ABC |
how to retrieve the value as XYZ for field SBU Head Email ID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 04:56 AM
you will have to use string manipulation for this
What if the format changes later on? your script won't work then
Please discuss with your customer on this format
try something like this if you are using inbound email action
Get the values from HTML table from an email in a Inbound Action
Inbound Email Action: Parse Data From Table in Email to Create Multiple Incidents
Inbound Email Action: - Extract data from an html table
check this if you are using inbound flow
Easiest way to Trigger Catalog Item Request via Inbound Email
How to read body text in Inbound EMAIL Flow
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
05-12-2025 04:58 AM
@SantanuKumar Sa Are you expecting the data to come in tabular format from emails?
Please refer to : https://www.servicenow.com/community/itsm-forum/get-the-values-from-html-table-from-an-email-in-a-in...
Please mark the answer helpful and correct if it resolves your issue. Happy Scripting 🙂
-Shantanu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 05:12 AM
Hello @SantanuKumar Sa ,
Please copy the findValue function shown below into your Inbound Email Action script.
function findValue(key) {
var re = new RegExp('<td[^>]*>' + key + '<\/td>[^<]*<td>([^<]+)<\/td>');
var matches = re.exec(email.body_text);
if (matches && matches.length === 2) {
return matches[1];
}
}
Given an inbound email with an HTML table like yours it will return the values you are looking for:
var email = {
body_text: '<p>some text</p>' +
'<table>' +
'<tr><td>SBU Head Email ID</td>\n<td>XYZ</td></tr>' +
'<tr><td>SBU</td><td>ABC</td></tr>' +
'</table>' +
'<p>some other text</p>'
};
gs.info(findValue('SBU Head Email ID'));
gs.info(findValue('SBU'));
Result:
XYZ
ABC
Regards,
Robert