Notification update
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
I have a development story for notification updation.
the current script is
//Fetching approval records that are in request state and approval user is inactive.
var approverGR = new GlideRecord('sysapproval_approver');
var encodedQuery = 'state=requested^source_table=sc_req_item^approver.active=false^group.assignment_groupISEMPTY';
approverGR.addEncodedQuery(encodedQuery);
approverGR.query();
while (approverGR.next()) {
var taskNumber = approverGR.sysapproval.number.toString();
var approverName = approverGR.approver.getDisplayValue();
var approvalLink = "https://"+gs.getProperty('instance_name')+".service-now.com/" + approverGR.getLink(true);
//Putting email content in body variable
var body = "Hello Team,<br/><br/>" +
"An inactive approver is assigned to a pending approval.<br/><br/>" +
"<b>Task Number:</b> " + taskNumber + "<br/>" +
"<b>Inactive Approver:</b> " + approverName + "<br/>" +
"<b>Approval Record:</b> <a href='" + approvalLink + "'>Click here</a><br/><br/>" +
"Regards,<br/>System";
//Event generation logic for generating notification
gs.eventQueue("nmbs.inactive.approver.notify", approverGR, taskNumber, body);
}
but now i need to modify it so that:
AS‑IS
- The Scheduled Script Execution “NMBS notify catalog manager for approval request of non active user” currently checks for inactive approvers in both individual and group approvals.
- When a group contains even one inactive user, the script sends a notification, even though other group members can still approve.
TO‑DO
- Update the Scheduled Script Execution logic to:
- Exclude group approvals from the notification process.
- Identify only individual approvers where:
- The assigned approver is a user (not a group)
- The user is inactive
- Trigger the notification only for inactive individual approvers.
TO‑BE
- The Scheduled Script Execution correctly handles approval logic by:
- Skipping all group approvals (no notifications triggered if group has inactive members).
- Notifying only for inactive individual users who have pending approvals.
After modification,
The Scheduled Script Execution must not send email notifications for group approvals, even if one or more members of the group are inactive.
The system must send an email notification only when the approver is an individual user who is inactive.
so what change should i make in this above script to incorporate the change
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
try this
//Fetching approval records that are in request state and approval user is inactive individual approver.
var approverGR = new GlideRecord('sysapproval_approver');
var encodedQuery = 'state=requested^source_table=sc_req_item^approver.active=false^approver.sys_class_name=sys_user';
approverGR.addEncodedQuery(encodedQuery);
approverGR.query();
while (approverGR.next()) {
var taskNumber = approverGR.sysapproval.number.toString();
var approverName = approverGR.approver.getDisplayValue();
var approvalLink = "https://"+gs.getProperty('instance_name')+".service-now.com/" + approverGR.getLink(true);
//Putting email content in body variable
var body = "Hello Team,<br/><br/>" +
"An inactive approver is assigned to a pending approval.<br/><br/>" +
"<b>Task Number:</b> " + taskNumber + "<br/>" +
"<b>Inactive Approver:</b> " + approverName + "<br/>" +
"<b>Approval Record:</b> <a href='" + approvalLink + "'>Click here</a><br/><br/>" +
"Regards,<br/>System";
//Event generation logic for generating notification
gs.eventQueue("nmbs.inactive.approver.notify", approverGR, taskNumber, body);
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Regards,
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
