Help with email script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2024 05:57 PM
Can anyone tell me why my email script is not allowing different open_by users to not be copied recipients on my notification? I believe it has to do with "if (current.opened_by && current.requested_for && current.opened_by != current.requested_for) { "
------------
Email Script:
function runMailScript(current, template, email, email_action, event) {
// Check if opened_by and requested_for are different
if (current.opened_by && current.requested_for && current.opened_by != current.requested_for) {
var openedByUser = current.opened_by;
// Add the opened_by user to the CC field
email.addAddress('cc', openedByUser.email, openedByUser.getDisplayValue());
}
}
runMailScript(current, template, email, email_action, event);
2 REPLIES 2

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2024 04:26 AM
function runMailScript(current, template, email, email_action, event) {
// Check if opened_by and requested_for are different
if (current.opened_by && current.requested_for && current.opened_by != current.requested_for) {
var openedByUser = current.opened_by;
// Add the opened_by user to the CC field
email.addAddress('cc', openedByUser.getValue('email'), openedByUser.getDisplayValue());
}
}
runMailScript(current, template, email, email_action, event);
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-28-2024 06:16 AM
Hi @Excalibur 583 Try below code
function runMailScript(current, template, email, email_action, event) {
if (current.opened_by && current.requested_for) {
if (current.opened_by.sys_id != current.requested_for.sys_id) {
var openedByUser = current.opened_by;
if (openedByUser.email) {
email.addAddress('cc', openedByUser.email, openedByUser.getDisplayValue());
}
}
}
}
runMailScript(current, template, email, email_action, event);