Inbound email actions
Turn incoming mail into records: action types, matching, watermark handling and safe scripting patterns.
Turn incoming mail into records: action types, matching, watermark handling and safe scripting patterns.
- Order matters, the first matching action wins
- Keep conditions tight so a Reply action never runs on a new message
- Never trust the body, strip signatures before writing to comments
- Test with a real mail client, previews do not reproduce header quirks
Three action types
New creates a record when the message has no watermark. Reply updates the record identified by the watermark or by the In-Reply-To header. Forward handles messages that were forwarded into the instance and is often used to create a record from a chain.
How a reply finds its record
ServiceNow adds a watermark to outbound notifications. When a user replies, that watermark tells the platform which record to update. If watermarking is disabled or the mail client strips the body, replies create duplicates instead of updating.
Writing the script
The action script has email, email_action and event available, plus current pointing at the target record.
// Reply action on incident
current.comments = 'Reply from ' + email.origemail + ':\n\n' + email.body_text;
if (current.state == 6 && email.body_text.length > 0) {
current.state = 2; // reopen on customer reply
}
current.update();