email action fields
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 03:39 PM
I have email action, The email i receive has the field names with space in between them and the parsing is not working. IS there a way to parse this?
Requested Type
In-Person
Alternate Type
Virtual
Date Requested
2025-04-22
Time Requested
10:15 a.m.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2025 12:09 AM
Hello @samadam ,
Spaces are rendered as underscores when a name : value pair gets parsed into a variable/value pair. E.g. "Requested Type" will get converted to Requested_Type. Inbound email script will create a variable as below :
email.body.Requested_Type
Try accessing the variables with spaces replacing with underscores.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2025 12:21 AM
Hello @samadam,
Could you please try the following:
var body = email.body_text; // Or email.body_html if you're parsing HTML
var lines = body.split('\n');
var data = {};
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim();
if (line === 'Requested Type') {
data.requested_type = lines[i + 1].trim();
} else if (line === 'Alternate Type') {
data.alternate_type = lines[i + 1].trim();
} else if (line === 'Date Requested') {
data.date_requested = lines[i + 1].trim();
} else if (line === 'Time Requested') {
data.time_requested = lines[i + 1].trim();
}
}
// Now use the data object to populate your record, Adjust as per your requirements
var gr = new GlideRecord('your_table');
gr.initialize();
gr.u_requested_type = data.requested_type;
gr.u_alternate_type = data.alternate_type;
gr.u_date_requested = data.date_requested;
gr.u_time_requested = data.time_requested;
gr.insert();