Trimm Inbound Email Script for Truncating Incoming Email Chain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2022 04:13 AM
Hi Community,
I have a requirement where I need to truncate the email chain in incoming emails. Only last email should be visible. I have tried the below code for this and trimmed 'from '
#. This just works fine with my User id( I can see only the latest email -but not truncated part ) - This should be the expected behaviour.Which
But When it is tested for other users, they are receiving the all email chain. I am not sure, how to fix this. Can somebody help ?
Here is my code for Update Incident ( Basically when User updates the incident, It should TRIMM all the incoming emails 'from' . I have tried email reply separators already , it does not help.
is There any better way to fix this ?
here is my code :
gs.include('validators');
if (current.getTableName() == "incident") {
var body = email.body_text;
/*
* The name of the sender of the message is stored in a property
* called glide.email.username. We want to leverage this when
* we strip off the original message.
**/
var system_user_name = gs.getProperty("glide.email.username");
/*
* Now look for the 'From: <System Email>' tag, so we can strip
* off the chain. ( ['F', 'r', 'o', 'm',':', ' '] = 6 )
**/
var beginInbound = body.indexOf(system_user_name) - 6;
if(beginInbound >= 0) {
// Strip off the original message
body = body.substring(0, beginInbound).trim();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2024 01:31 PM
I created a HI case for this and ServiceNow gave me a workaround and created a problem ticket:
PRB1766694 - Email reply separators do not work for HR related email