create email notification for a inactive user of the group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 02:13 AM
Hi All,
It is first time to work on the wmail notification. I need to create an email notification the following conditions where the target groups are those that start with API..
1. When a ServiceNow Group member's account becomes inactive: Emails will be sent to the Group Manager and Group Member, with cc to the CMDB team
2. When a ServiceNow Group manager's account becomes inactive: Emails will be sent to the Group Member, with cc to the CMDB team
Can I create both the condition in one email notification or need to create separate notification?
Can it be done with email notification setting or should I use flow designer?
It will be helpful if anybody help me with script to send the notification for the above conditions?
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You should be able to find the user is user record condition as sys_user_grmember table only. I have used the same as groups and it's associated users are referenced in this table only.
Please send a screenshot of possible.
Thanks and Regards,
K. Sai Charan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @PyLaRue ,
I have checked in my pdi and I was able to see the option to select the user filter condition. Please find the attached screenshot.
If you are still not able to find in yours, then try creating a new flow and try once again.
Please mark my answer "Helpful" and "correct" if you feel that it has helped you in any way.
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2025 04:43 AM
ou have two different conditions for triggering email notifications:
- When a Group Member becomes inactive
- When a Group Manager becomes inactive
Should I create one or two notifications?
It's best to create two separate notifications because:
- Each condition has different recipients.
- It will be easier to manage and troubleshoot.
- ServiceNow notifications trigger based on conditions, so separating them ensures accuracy.
Can it be done using Email Notifications or Flow Designer?
- If you want a simple solution, use Email Notifications in ServiceNow. This works if the conditions can be set using standard filters.
- If more flexibility is needed (e.g., advanced logic or multiple conditions), use Flow Designer with an action to send emails.
Steps to Configure Email Notification (Using Email Notification Module)
- Navigate to: System Notification > Email > Notifications
- Click "New" to create a new notification.
- Fill in details:
- Name: Notify on Group Member Inactivation
- Table: sys_user
- Condition: Active is false AND Group starts with API
- Who will receive?
- To: Group Manager (group.manager)
- CC: CMDB Team (Add manually or use a group field)
- Add email template: Define your subject and message.
- Save and Activate the Notification.
Repeat these steps for the Group Manager condition.
Using Flow Designer (For Advanced Logic)
If you want more control, use Flow Designer:
- Navigate to: Flow Designer > Create a new Flow
- Trigger: When a sys_user record is updated
- Condition: Active is false AND Group starts with API
- Action: Use Send Email action
- Define Recipients: Use Lookup Records to find the right group manager/members.
- Save and Activate the Flow.
Script Example for Flow Designer (If Needed)
If you need a script to dynamically send emails, you can use a script action in Flow:
(function executeRule(current, previous /*null when async*/) {
var group = current.getValue('sys_user_group');
if (group && group.startsWith('API')) {
var emailRecipients = [];
var grGroup = new GlideRecord('sys_user_group');
if (grGroup.get(group)) {
// Add Group Manager
if (grGroup.manager) {
emailRecipients.push(grGroup.manager.email);
}
// Add Group Members
var grMembers = new GlideRecord('sys_user_grmember');
grMembers.addQuery('group', group);
grMembers.query();
while (grMembers.next()) {
emailRecipients.push(grMembers.user.email);
}
}
// Send Email
gs.eventQueue("custom.email.notification", current, emailRecipients.join(','), "CMDB_Team@example.com");
}
})(current, previous);
