- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 06:02 AM
HI Community,
I have a requirement, when additional comment is update in REQ (request) then the comments need to be sent to the approver of the RITM (notification need to be sent).
So i have created a event reg and business rule to trigger that but notification is not getting triggered
update after BR on sc request table
event
notification event is fired and written on sc request table
can you guys help me what is wrong in here
Thanks in Advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 07:10 AM
did the event get processed?
your script is wrong, approval is always for RITM and not on REQ so your addQuery won't work
try this
(function executeRule(current, previous /*null when async*/ ) {
var lastComments = current.comments.getJournalEntry(1);
var approverList = [];
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', current.sys_id);
ritm.query();
if (ritm.next()) {
var sysApprovalGR = new GlideRecord("sysapproval_approver");
sysApprovalGR.addEncodedQuery("sysapproval=" + ritm.getUniqueValue() + "^state=requested");
sysApprovalGR.query();
while (sysApprovalGR.next()) {
approverList.push(sysApprovalGR.getValue("approver"));
}
if (approverList.length > 0 && lastComments) {
gs.eventQueue("sc_req.commented.approver.req", current, approverList.toString(), lastComments);
}
}
})(current, previous);
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
04-08-2025 06:23 AM - edited 04-08-2025 06:24 AM
@suuriyas I tried your code in PDI and it triggered notification.
Event is fired
Emails are present in Email log table - (sys_email)
Below is my notification record. Compare this with your notification record. See if you added any additional condition.
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 07:10 AM
did the event get processed?
your script is wrong, approval is always for RITM and not on REQ so your addQuery won't work
try this
(function executeRule(current, previous /*null when async*/ ) {
var lastComments = current.comments.getJournalEntry(1);
var approverList = [];
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', current.sys_id);
ritm.query();
if (ritm.next()) {
var sysApprovalGR = new GlideRecord("sysapproval_approver");
sysApprovalGR.addEncodedQuery("sysapproval=" + ritm.getUniqueValue() + "^state=requested");
sysApprovalGR.query();
while (sysApprovalGR.next()) {
approverList.push(sysApprovalGR.getValue("approver"));
}
if (approverList.length > 0 && lastComments) {
gs.eventQueue("sc_req.commented.approver.req", current, approverList.toString(), lastComments);
}
}
})(current, previous);
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