Parsing Inbound Email after Yokohama
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2025 10:20 AM
Is anyone experiencing issues of parsing of name/value pairs for Inbound Email after Yokohama. I am noticing that my incident fields are populating to the name/value pair I had set in my script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2025 10:27 PM
share your script which was working earlier.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2025 10:52 PM
Hi @athavichith ,
Yes, after the Yokohama upgrade, several users have reported issues with how name/value pairs are parsed from inbound emails. In earlier versions of ServiceNow, if you included name/value pairs in the email body (like short_description=Network issue), the system would interpret them more leniently and populate the corresponding fields. However, in Yokohama, the inbound email processing logic has been updated and now handles parsing more strictly. This means that if the format isn’t exactly right, or if the field isn’t writable or recognized, the values might be ignored or incorrectly applied. As a result, some fields on the incident or other records might be populated with the literal name/value strings instead of properly parsed values.
To work around this, it’s recommended to directly set field values in your inbound email script using target.fieldname = value rather than relying on body parsing. If you still want to use name/value parsing, ensure each pair is correctly formatted on a new line and matches valid field names. You can also disable automatic parsing using email.parseBody = false and manually extract the values from the body. Reviewing the sys_email logs can also help identify how the email was processed and why fields were not updated as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2025 06:26 AM
Thank you Tejas!
Here is my script:
Here is sample inbound email:
Name: John Doe
Phone: 1 555-555-5555
Email: Edward.Anderson@test.com
Location: Headquarters
theITSupportCenter Information:
ITSC Ticket Number: 01427108
Case Date: 4/28/2025
Category: Application
Incident Subcategory: ServiceNow
Description:
AdvisorCommentJeff HolmesA: Test case no serviceJeff HolmesSending test case notificationJeff Holmestest commentJeff Holmestest test test
Thank you for assisting the Customer
C1TM3CKNC23SBLEIBL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-30-2025 07:00 AM
try this
(function runAction(current, event, email, logger, classifier) {
// Function to convert a string to title case
function toTitleCase(str) {
return str.toLowerCase().replace(/\b\w/g, function(char) {
return char.toUpperCase();
});
}
// Extract the phone number from the email body
var phoneNumber = email.body.match(/Phone:\s*(\d+)/i);
if (phoneNumber) {
phoneNumber = phoneNumber[1];
// Remove leading "1" from phone number if present
if (phoneNumber.startsWith("1")) {
phoneNumber = phoneNumber.substring(1).trim();
}
}
// Extract other fields from the email body
var name = email.body.match(/Name:\s*(.*)/i);
var location = email.body.match(/Location:\s*(.*)/i);
var category = email.body.match(/Category:\s*(.*)/i);
var subcategory = email.body.match(/Incident Subcategory:\s*(.*)/i);
var briefDescription = email.body.match(/Description:\s*(.*)/i);
// Convert category and subcategory to title case
category = category ? toTitleCase(category[1]) : '';
subcategory = subcategory ? toTitleCase(subcategory[1]) : '';
// Set location
var locationName = location ? toTitleCase(location[1]) : '';
var locationSysId = getLocation(locationName);
if (locationSysId) {
current.location = locationSysId;
}
// Map fields to the current record
current.caller_id = name ? name[1] : '';
current.u_best_contact_phone_num = phoneNumber;
current.category = category;
current.subcategory = subcategory;
current.work_notes = briefDescription ? briefDescription[1] : '';
// Assignment groups
var afterHoursGroup = '0f32deb09773995030aab2a3f153af35';
var serviceDeskGroup = '4b329e3c97fb9550cc467d021153afd1';
// Instantiate GlideSchedule with your cmn_schedule sys_id
var schedule = new GlideSchedule('090eecae0a0a0b260077e1dfa71da828'); // 6:30AM to 5:00PM weekdays excluding holidays schedule
var now = new GlideDateTime();
// Check if current time is within business hours
var isBusinessHours = schedule.isInSchedule(now);
if (isBusinessHours) {
current.assignment_group = serviceDeskGroup;
} else {
current.assignment_group = afterHoursGroup;
}
function getLocation(location) {
var locgr = new GlideRecord('cmn_location');
locgr.addEncodedQuery('u_display_nameSTARTSWITH' + location); // or use 'name' depending on your instance setup
locgr.query();
if (locgr.next()) {
return locgr.sys_id.toString();
}
return null;
}
})(current, event, email, logger, classifier);
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