Send Email Notification to Assigned to when Additional Comment is added

Jonathan102
Tera Guru

Hi,

 

I am trying to create an email notification to be sent to the Assigned to of a SCTASK when an end user/opened by adds a new comment through the service portal.  The issue we are facing is when a user adds a comment to the ticket (RITM) in the portal, we don't know unless we continually open the ticket and look.

 

Thanks,

Jonathan 

1 ACCEPTED SOLUTION

Robert H
Mega Sage

Hello @Jonathan102 ,

 

Here is solution that will not only trigger a notification but also copy the user's comment to the Work notes of the SCTASK itself for better visibility.

 

Create a new Business Rule configured like this:

RobertH_0-1743706443564.png

 

Put the following code into Advanced > Script, or adjust as desired.

(function executeRule(current, previous /*null when async*/ ) {

    var grTasks = new GlideRecord('sc_task');
    grTasks.addQuery('request_item', current.getUniqueValue());
    grTasks.query();
    while (grTasks.next()) {
        grTasks.work_notes = 'Comment added to RITM: ' + current.comments.getJournalEntry(1);
        grTasks.update();
    }

})(current, previous);

 

This will trigger the OOTB "Catalog task worknoted" Notfications to the task Assignee or Assignment group.

 

I verified that this works fine in Service Portal.

 

Regards,

Robert

View solution in original post

10 REPLIES 10

Shivalika
Mega Sage

Hello @Jonathan102 

 

You can create an email notification on sctask table 

 

With below 👇 conditions - 

 

REQUESTitem.Additional Comments Changes 

 

In the recipient add Assigned to 

 

Add whatever you want in subject and body. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

Thank you for the suggestion but this doesn't work, I've already tried it.  If the comment is added directly on the RITM, it works.  However, if it's made on the RITM through the Service Portal (under my tickets) it does not trigger the email.  It has something to do with the sys_journal table/field and thats what I am trying to figure out.

Thank you,

Jonathan 

Hello @Jonathan102 

 

Did you add another condition that updated by caller ? So that it can be identified who exactly posted a comment. 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY

Robert H
Mega Sage

Hello @Jonathan102 ,

 

Here is solution that will not only trigger a notification but also copy the user's comment to the Work notes of the SCTASK itself for better visibility.

 

Create a new Business Rule configured like this:

RobertH_0-1743706443564.png

 

Put the following code into Advanced > Script, or adjust as desired.

(function executeRule(current, previous /*null when async*/ ) {

    var grTasks = new GlideRecord('sc_task');
    grTasks.addQuery('request_item', current.getUniqueValue());
    grTasks.query();
    while (grTasks.next()) {
        grTasks.work_notes = 'Comment added to RITM: ' + current.comments.getJournalEntry(1);
        grTasks.update();
    }

})(current, previous);

 

This will trigger the OOTB "Catalog task worknoted" Notfications to the task Assignee or Assignment group.

 

I verified that this works fine in Service Portal.

 

Regards,

Robert