Email notification and additional comments.

Maxwell3
Kilo Guru

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.

1 ACCEPTED SOLUTION

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!

View solution in original post

12 REPLIES 12

Allen Andreas
Administrator
Administrator

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!

Sandhya3
Kilo Expert

Hi Maxwell,

 

If you select "Additional Comments" under the condition of when to trigger there's an option called "changes" that you can use to trigger the email.find_real_file.png

 

If you find it helpful please do mark it as Correct and helpful

 

Thanks and regards

S Sandhya

Sandhya3
Kilo Expert

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.find_real_file.png

 

Please mark helpful and correct in case you find it helpful.

 

Thanks and Regards

S Sandhya

Maxwell3
Kilo Guru

So here is what I have so far. I am not sure if I can query tables in the email notification condition builder's Advanced Condition, as Allen has mentioned.

find_real_file.png