only lastest additional comments should send via email
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 06:05 AM
Hi,
I have a notification email configured , for which I am looking for implementation ideas.
need solution for : email should only send the latest additional comments .
•If mail is sent to customer with text ABC( in additional comments ) , ( offcourse : it needs to be added to INC# history)
Email 1 outbound : ABC ( BODY TEXT)
•If customer replies later with text DEF, only the reply information DEF must be added
Email 2 : reply mail to Email 1 : Inbound Email : DEF ( BODY TEXT) , ABC - Should not be visible .
•Goal is to avoid having the original ABC message copied again, which would pollute the ticket history if there are numerous mails going back and forth and each time, the full message would be copied into the ticket again.
How to code this ? Can someone provide with code snippet ?
TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 06:08 AM
you can use email script and include that email script in email body.
Email script will fetch the latest comments and print it
Something like this
var fieldName = 'comments';
var rec = new GlideRecord('sys_journal_field');
rec.orderByDesc('sys_created_on');
rec.addQuery('name', current.getTableName());
rec.addQuery('element', fieldName);
rec.addQuery('element_id', current.sys_id);
rec.setLimit(1);
rec.query();
if(rec.next()){
template.print("Latest comments: "+ rec.value);
}
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
10-18-2022 06:21 AM
Hi Ankur,
Where should we write this script ? is this Email notification scripts ? Inbound Email action Scripts ? Can we use Email Reply Seperators here ? Could you please advice how ?
TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 06:25 AM
Email script.
Check this link and explanation
Scripting for email notifications
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2022 06:15 AM
Hi Check the below thread.
How to get the most recent email body text and ign... - ServiceNow Community
Trail mail can be identified in the Body content using keywork "From:"
You can use this logic to trim the comment after this key word.