- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2025 06:47 PM
Hello,
When a change request is approved, I need to trigger a notification to both the "Created By" and "Opened By" users to let them the change has been approved.
I have set up the event registry, business rules, and notification, but the email is not being triggered. Could someone please take a look and suggest how to fix this? Thank you
Registry:
Business Rule on Change Request Table:
Advanced Tab:
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.addQuery('state', 'approved');
gr.query();
while (gr.next()) {
gs.info('Start');
gs.eventQueue('Change.approved.notification', current, gr.created_by, gr.openend_by, current);
gs.info('End');
}
})(current, previous);
Notification:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2025 10:37 PM
created by and opened by will be same for CHG
So you will have to tweak it like this
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.addQuery('state', 'approved');
gr.query();
while (gr.next()) {
gs.info('Start');
gs.eventQueue('Change.approved.notification', current, current.opened_by.toString(), '');
gs.info('End');
}
})(current, previous);
I hope your BR is configured correctly then it will work fine
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
01-19-2025 06:39 AM
so you are saying you want to send email to requested_by as well?
if yes then do this
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.addQuery('state', 'approved');
gr.query();
while (gr.next()) {
gs.info('Start');
gs.eventQueue('Change.approved.notification', current, current.opened_by.toString() + ',' + current.requested_by.toString());
//gs.eventQueue('Change.approved.notification', current, current.opened_by.toString(), '');
gs.info('End');
}
})(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
01-16-2025 06:54 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2025 07:16 PM
There is an opened_by file on the approval table:
Is Business Rule script looks correct to you?
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.addQuery('state', 'approved');
gr.query();
while (gr.next()) {
gs.info('Start');
gs.eventQueue('Change.approved.notification', current, gr.opened_by, gr.created_by, current);
gs.info('End');
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2025 10:37 PM
created by and opened by will be same for CHG
So you will have to tweak it like this
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.addQuery('state', 'approved');
gr.query();
while (gr.next()) {
gs.info('Start');
gs.eventQueue('Change.approved.notification', current, current.opened_by.toString(), '');
gs.info('End');
}
})(current, previous);
I hope your BR is configured correctly then it will work fine
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
01-17-2025 08:31 AM
Thank you so much for your help. I would like to learn how to add a second parameter for the "requested for" field. Could you please guide me on how to do that?
I tried below script and that did not goes well. Thanks you
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sysapproval_approver');
gr.addQuery('sysapproval', current.sys_id);
gr.addQuery('state', 'approved');
gr.query();
while (gr.next()) {
gs.info('Start');
gs.eventQueue('Change.approved.notification', current, current.opened_by.toString(), current.requested_by.toString());
//gs.eventQueue('Change.approved.notification', current, current.opened_by.toString(), '');
gs.info('End');
}
})(current, previous);