- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2017 10:51 AM
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.
However, the Updated date still shows 2017-06-15 10:38:22.
Does anyone know how to fix this?
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2019 10:03 AM
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:
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-10-2019 11:02 PM
Where do you write the script?
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-11-2019 10:03 AM
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:
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2020 04:37 PM
Hey this worked for me almost.
My incident now updates the date at which the email was sent which is great, but the Updated By field shows "system" instead of the "itsender" (Update By field should populate the last sender).
Do you have an update for that?
Updated By should be Nathan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-03-2020 04:57 PM
The Business Rule is updating the ticket after the email is sent, so it's the "system" that is actually copying the email body to the incident. I don't believe there is a way to force it to run as the user.
However, I think you may be able to create a Flow (using Flow Designer) to do this instead of using a Business Rule. Flows can be set to run as the user or as system, so that may be your best bet. Good luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2020 10:28 AM