Why does the updated date not change after sending an email from within the incident?

Amanda Stoupa
Tera Guru

Why does the updated date not change after sending an email from within an incident? Our helpdesk often sends emails from within ServiceNow to our customers, but since the updated date doesn't change after sending an email, it's difficult to see when the incident was actually last updated. See example below:

I created an incident and posted an additional comment and it shows a date/time in the activity log of 2017-06-15 10:38:22. I then sent an email from within the incident and it shows in the activity log as being sent at 2017-06-15 10:42:34.

find_real_file.png

However, the Updated date still shows 2017-06-15 10:38:22.

find_real_file.png

Does anyone know how to fix this?

1 ACCEPTED SOLUTION

Hi Deepali,
Sachin was referring to a Business Rule, created on the sys_email table. However, I don't think forcing the Updated [sys_updated_on] field to update, instead of letting it update automatically is best practice.

I ended up copying sent email from the email client to the Additional comments, and then updating my notifications so don't send a duplicate of the previously sent email (I added filter condition: updated_by is not system). Since updating Additional comments updates the Updated [sys_updated_on] field, this solved my problem.

This is the Business Rule on the sys_email table I created to copy sent email from the email client to the Additional comments:

find_real_file.png

Script on Advanced tab:

copyComments();

function copyComments() {
    // Verify if the mail was sent from the mail client and not a Notification
    var headers = current.headers;
    var isMailClient = headers.search("X-ServiceNow-Source: EmailClient");
    
    if (isMailClient != -1) {
        var incident = new GlideRecord('incident');
        incident.addQuery('sys_id', current.instance);
        incident.query();
        // Copy the body of the email to the additional comments
        while(incident.next())
            {
            var str = '[code]' + current.body + '[/code]';
            var itsender = current.sys_created_by;
            incident.comments = "An email was sent by " + itsender + "\n\n" + str;
            incident.update();
        }
    }
}

 

Hopefully this helps!

View solution in original post

10 REPLIES 10

Hi @Amanda Stoupa , 

I am still not getting the updated field updated whenever the email is sent in the activities section. 

Please find the screenshots and could you help me if possible?

I have also tried it @sac2 way , but still the issue persists

 

ShwethaShenoy_0-1700890953385.png

ShwethaShenoy_1-1700890962900.png

Thanks is advanced !