Email Notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 02:07 AM
Hello all,
Can anyone suggest how to add email addresses to a designated team using a script in Event record.
Regards,
Dhanush
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2024 07:01 AM
Hi Dhanush,
Can you try with below code in a Business rule -
// Get the team record based on the team's unique identifier
var teamGR = new GlideRecord('sys_user_group');
if (teamGR.get('unique_identifier', 'your_team_unique_identifier')) {
// Add email addresses to the team's members field
var members = teamGR.getValue('members'); // Assuming 'members' is a field storing members' details
var newEmails = "new.email@example.com,new.email2@example.com"; // Example email addresses to add
var updatedMembers = members + ',' + newEmails;
teamGR.setValue('members', updatedMembers);
teamGR.update();
gs.info("Email addresses added to the team successfully.");
} else {
gs.error("Team not found.");
}
Please mark my answer helpful if it worked for you.