- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2020 10:14 AM
Hello all,
Is there a way to trigger email notifications per the amount of Additional Comments?
So, if there is 1 additional comment the email notification would say Update 1 and if there is 2 Additional comments, the notification would say Update 2 and so on. These notifications will be triggered by the amount of additional comments in the current incident.
Right now, the notification is being triggered per update count but that is not efficient, the notification needs to be triggered per Additional comments count.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2020 05:22 PM
Hi,
Firstly, please mark any other reply of mine thus far as "Helpful", if it was.
Secondly, you could try something like this:
var setID;
var gr2 = new GlideRecord('sys_history_set');
gr2.addQuery('id', current.sys_id);
gr2.query();
if (gr2.next()) {
setID = gr2.sys_id;
}
var gr = new GlideRecord('sys_history_line');
gr.addQuery('set', setID);
gr.addQuery('field', 'comments');
gr.orderByDesc('sys_created_on');
gr.query();
if (gr.next()) {
template.print('gr.getDisplayValue('update'));
template.print('<br />');
}
So you have to grab the set for the history line "package". So you can get this by glide querying with the current.sys_id (so the current record this script is ran on), then we're tossing that over to a variable that we are going to use later in another glide query on the actual history line package, filtering those results for only records part of that set, then only comments, then only the latest comment, and then displaying that value update #.
However, if you're just trying to get the count of entries for "comments" then you can do: gr.getRowCount(); for example
https://developer.servicenow.com/app.do#!/api_doc?v=newyork&id=r_GlideRecord-getRowCount
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2020 10:32 AM
Hi,
I assume you could write a mail script that queries perhaps the sys_history_line table and does a count for the "additional comment" field and then you'd use that to grab the update count.
If you go to any Incident, for example, and view history, you can see what I'm talking about.
Try that?
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2020 10:39 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2020 10:43 AM
Hi Maxwell,
You can select "Additional Comment" under the condition builder of when to send ,it has an option as "changes" so the email would be triggered under condition only.I have attached the image for better understanding.
Please mark helpful and correct in case you find it helpful.
Thanks and Regards
S Sandhya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-04-2020 11:55 AM