The email client is not updating 'sys_updated_on' field

Pelo Ntwampe
Mega Sage

Hi,

I have an issue that, when an email is sent using the email client, the 'sys_updated_on' field is not updated with the date/time of the update. The activity is updated with the correct date/time, but this is not reflected in 'sys_updated_on' - i.e. the Updated field.

When updating using Additional comments or just updating Work notes for someone on the Work notes list, the 'sys_updated_on' captures all these updates correctly. They're reflected in both Activity and 'Updated' field.


Any ideas?


Thank you.

NB: I tested this with Incident, Change and Problem.

1 ACCEPTED SOLUTION

aessling
Mega Expert

Though I could not get the above business rule to work I was able to combine it with another business rule that I found and got it to work.


Table: Email [sys_email]


When = After


Insert and Update Checked


Condition:


current.type == 'sent' && current.headers.indexOf('X-ServiceNow-Source: EmailClient') > -1



Script:



function onAfter(current, previous) {


    //This function will be automatically called when this rule is processed.


var record = new GlideRecord(current.target_table);


//Grab the email message that matches the record


record.addQuery('sys_id', current.instance);


record.query();


if (record.next()) {


record.sys_updated_on = gs.getNowDateTime();


  record.update();


  }


}


View solution in original post

10 REPLIES 10

Hi Jack,



The business rule that Anthony provided works.



Thank you, Anthony.



Regards,


Pelo


aessling
Mega Expert

Though I could not get the above business rule to work I was able to combine it with another business rule that I found and got it to work.


Table: Email [sys_email]


When = After


Insert and Update Checked


Condition:


current.type == 'sent' && current.headers.indexOf('X-ServiceNow-Source: EmailClient') > -1



Script:



function onAfter(current, previous) {


    //This function will be automatically called when this rule is processed.


var record = new GlideRecord(current.target_table);


//Grab the email message that matches the record


record.addQuery('sys_id', current.instance);


record.query();


if (record.next()) {


record.sys_updated_on = gs.getNowDateTime();


  record.update();


  }


}


Hi Anthony,



Thank you for this - works perfectly.



Regards,


Pelo


marskh111
Giga Contributor

This doesn't seem to be working for me? Is all that needed to be done create that single business rule? Am i missing anything else?



find_real_file.png


Yes, this was all I had to do. Make sure Insert and Update are checked.