- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2025 06:27 AM - edited 08-05-2025 02:25 PM
Hi,
When an approver is approving via email, the below should be sent to them:
"If you would like to enter comments, place them between the starred lines below, then click Send:
******************************************************************************
(comment entered by approver)
****************************************************************************** "
When the email is received, the comments entered by the approver should be written to the approval record, just the comment itself (and not the surrounding text) should be written to the approval record.
We can update the content on email templates (mailto.rejection and mailto.approval), but not sure how to remove surrounding content, can you please assist?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2025 07:09 AM
for removing the surrounded content, you will have to update the OOTB inbound action and use string manipulation to extract the comments
Something like this worked for me, so please enhance as per your requirement
// Simulated email body with instructional text and approver comment
var emailBody = "If you would like to enter comments, place them between the starred lines below, then click Send:\n" +
"******************************************************************************\n" +
"This is the comment entered by the approver.\n" +
"Please review carefully.\n" +
"******************************************************************************\n" +
"Additional trailing text or signature";
// Regex to capture content between 78 or more stars (asterisks)
var regex = /[*]{78,}\s*([\s\S]*?)\s*[*]{78,}/m;
// Extract the comment
var match = regex.exec(emailBody);
var comment = "";
if (match && match[1]) {
comment = match[1].trim();
}
// Output the extracted comment for confirmation
gs.info("Extracted comment:\n" + comment);
You can update like this
var body = email.body_text;
var comment = '';
var re = /[*]{78,}\s*([\s\S]*?)\s*[*]{78,}/m; // Match 78+ stars and capture what’s between
var match = re.exec(body);
if (match && match[1]) {
comment = match[1].trim();
}
// Set the comment on the approval record (example for a task approval)
current.comments = comment;
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
08-06-2025 08:12 PM
Glad to know that script worked.
To test you will have to use DEV instance and enable incoming email.
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
08-07-2025 06:19 AM
@Ankur Bawiskar Yes, I have enabled incoming email from email properties but it says that the delivery has failed. Checking if there is anything else that needs to be configured?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 06:23 AM
in your DEV when you enabled incoming email, you need to enable sending also
1) send email for approval and let it come to your email address (the approver to whom approval is requested, in his/her profile add your email address OR make yourself as the approver)
2) add your email address in this field so that emails come only to your mail box and not for others
3) then reply to that email with that string which you added in question
4) check the inbound action triggered or not and then processed or not, add some logs and then verify if the content was extracted or not.
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
08-07-2025 09:25 AM
We have outgoing email enabled to a test mail box and can see approval emails over there. After inputting the approval comments on email and sending it back to ServiceNow, it is getting failed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 07:30 PM
email is not coming to ServiceNow?
If yes then it's another issue and nothing to do with inbound action.
your inbound action will run when email comes to instance.
May be there are some email filters in your instance which are blocking the incoming email, please check that
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