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

brian_quinn
ServiceNow Employee
ServiceNow Employee

What are you using the 'Updated' field for where this causes an issue?   There may be a better way to handle this depending on what your use case is, but one way to accomplish this is to write a business rule against the sys_email table.



The BR would fire when a new sys_email record is created, marked send-ready, and the header contains "X-ServiceNow-Source:EmailClient" and the would be something like this:



var gr = new GlideRecord(current.target_table);


gr.get(current.instance);


gr.sys_updated_on = gs.getNowDateTime();


gr.update();



Thanks


Brian


Hi Brian,



We are using the Updated field in reports to determine when a record was last updated. As an example, we have a report that provides us with a list of tasks that were not updated over the past week or two weeks, etc.



When a member of our Helpdesk updates a record using just the email client instead of Additional comments or Work notes, the date/time of when the email was Sent from the system is recorded in the activity of the record, but this information does not update the 'Updated' field. So, our reports become inaccurate.



Thanks for the suggestion. I was wondering whether a BR will be the best option for this.



Regards,


Pelo


Hi there,



how did you go about doing this in the end? We have a similar use case.



Thanks,


Jack


Hi Jack,



We have not tested this yet. I considered adding a business rule that checks when a notification is sent from a Incident record and then updates the "Updated" field with the current date&time.



I will update you when we make progress.



Regards,


Pelo