Help Needed: Notification to Approvers on New RITM Comment

Lisa Goldman
Kilo Sage

Hi,

I need your help with a notification issue. We have a catalog item with multiple approvers. When a new comment is

 

added to the associated RITM, we want to notify all approvers with the latest comment.

 

I’ve attempted to implement this, but it’s not working as expected. Here’s what I’ve done so far:

 

EVENT Name: ritm.new.comment

 

LisaGoldman_0-1750971381035.png

 

BUSINESS RULE:

  • Run after update
  • Script
(function executeRule(current, previous /*null when async*/ ) {

    var lastComments = current.comments.getJournalEntry(1);
    var arr = [];
    var sysApprovalGR = new GlideRecord("sysapproval_approver");
    sysApprovalGR.addEncodedQuery("sysapproval=" + current.getUniqueValue();
    sysApprovalGR.query();
    while (sysApprovalGR.next()) {
        arr.push(sysApprovalGR.getValue("approver"));
    }
    gs.eventQueue('ritm.new.comment', current, arr.toString(), current.getDisplayValue('approver'));

})(current, previous);

 

NOTIFICATION:  Tigger on sc_req_item Table

 

LisaGoldman_1-1750971619197.png

 

LisaGoldman_2-1750971653104.png

 

LisaGoldman_3-1750971714150.png

 

 

Any guidance or suggestions would be greatly appreciated.

Thanks,

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Lisa Goldman 

try these changes

1) update business rule logic to send latest comments as event parm2 and closing bracket is updated in encodedQuery

2) in email body use this to print the latest comments (you are not sending it so approvers won't know the comments)

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

    var lastComments = current.comments.getJournalEntry(1);
    var arr = [];
    var sysApprovalGR = new GlideRecord("sysapproval_approver");
    sysApprovalGR.addEncodedQuery("sysapproval=" + current.getUniqueValue());
    sysApprovalGR.query();
    while (sysApprovalGR.next()) {
        arr.push(sysApprovalGR.getValue("approver"));
    }
    gs.eventQueue('ritm.new.comment', current, arr.toString(), lastComments);

})(current, previous);

In Email body use this

Latest comments are: ${event.parm2}

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

@Lisa Goldman 

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

    var lastComments = current.comments.getJournalEntry(1);
    var arr = [];
    var sysApprovalGR = new GlideRecord("sysapproval_approver");
    sysApprovalGR.addEncodedQuery("sysapproval=" + current.getUniqueValue());
    sysApprovalGR.query();
    while (sysApprovalGR.next()) {
        //arr.push(sysApprovalGR.getValue("approver"));
        arr.push(sysApprovalGr.getDisplayValue('approver')); // Get the user's display name
    }
    gs.eventQueue('ritm.new.comment', current, arr.toString(), lastComments);

})(current, previous);

 

@Lisa Goldman 

you can pass the name of the approvers in event.parm1 but remember it won't send email then

Event parm1 or Event parm2 should contain the user sysIds so that system knows whom to send the email

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader