- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 02:02 PM
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
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
Any guidance or suggestions would be greatly appreciated.
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-26-2025 08:41 PM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2025 08:53 AM
(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);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2025 09:08 AM
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.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader