Notifications

86 views

Description

Problem


When sending an mail with the mail client in an incident, sys_updated_on does not the 'updated' timestamp of the related record (e.g. incident).

Symptoms


If you send an Email using the Email client that you can access from menu top bar in any incident.

The Email sent created an activity, but this new activity shown in the Activities journal entries does not update the main parent incident record and the incident system timestamp "sys_updated_on" does not get updated either

This was intended behavior for Emails not to update their related records, however there may be situations when this is necessary.

Cause


The email client does not perform an update on the related record

Resolution


There is no plans to change this behavior.

Instead, you could customise the system to perform an update once an email is sent by the email client.

Here is an example

Scripted business rule on sys_email table as follow:

 

Table [sys_email]
When BEFORE UPDATE
Order =100
target table is incident AND
Weight is -1 AND
Type ChangesTo sent

Script =

 
(function executeRule(current, previous /*null when async*/ ) {
    // Look up the target record 'instance' in the incident table 
    var curtim = new GlideDateTime();
    var inc1 = new GlideRecord('incident');
    inc1.addQuery('sys_id', current.instance);
    inc1.query();

    if (inc1.next()) {
        inc1.sys_updated_on = curtim;
        inc1.update();
        gs.log("Email sent by user, incident " + inc1.number + " sys_updated_on updated with timestamp " + curtim);
    }
})(current, previous);
Warning: Please fully test on development before making changes to production

 


 

Article Information

Last Updated:2019-08-30 02:16:58
Published:2019-03-01