Can someone help me edit my advance condition script for email notification?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 02:11 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2024 03:48 PM
Not sure if you can use something like current.sysevent_email_action.recipient_groups. Is there a possibility to use events instead so that you can run this logic in a Business rule and then pass the group sysid in an event?
Also you are passing name of the group instead of sysid in below line.
current.sysevent_email_action.recipient_groups = recipientGroups;
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-06-2024 09:27 AM
Hello @yjeon92 ,
Can you add few debug logs to your code and try once.
(function() {
var demand = new GlideRecord('dmn_demand');
if (demand.get(current.demand)) {
var openedByUser = new GlideRecord('sys_user');
if (openedByUser.get(demand.opened_by)) {
var department = new GlideRecord('cmn_department');
if (department.get(openedByUser.department)) {
var businessUnit = department.business_unit.name;
var recipientGroups;
switch(businessUnit) {
case 'HR':
recipientGroups = 'HR Team';
break;
case 'Audit':
recipientGroups = 'Audit Team';
break;
case 'Account Receivable':
recipientGroups = 'Account Receivable Team';
break;
case 'Account Payable':
recipientGroups = 'Account Payable Team';
break;
// Add more cases for other business units if needed
default:
recipientGroups = 'HelpDesk';
}
gs.info('Recipient Groups: ' + recipientGroups);
current.sysevent_email_action.recipient_groups = recipientGroups;
} else {
gs.info('Department record not found for user: ' + openedByUser.getDisplayValue());
}
} else {
gs.info('Opened by user record not found for demand: ' + demand.getDisplayValue());
}
} else {
gs.info('Demand record not found');
}
})();
Please Mark My Answer as Helpful and Accept as Solution, if you find this article helpful or resolves your issue.