
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2024 05:29 PM
Hi all, I have successfully built a mail script to add to a subject line if a field is not empty, however I now also need this to add a recipient to the outbound notification email, if that same field is populated.
i.e. if the current.u_vendor_reference_number != '' then add matt.test@matt.com.au to the list of existing recipients of that notification.
1. the u_vendor_reference_number is on the change_request table
2. I not only need this on change related notifications, but also on the approval notifications (using OOB currently)
3. This is my current mail script I'd like to add to if possible -
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var subj = email.getSubject();//get current subject from notification
var checkref = current.u_vendor_reference_number;
if (checkref != '') {
email.setSubject(subj + ' | Ticket #' + checkref);
}
})(current, template, email, email_action, event);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2024 07:55 PM
Hi @mattmm - You can do something like this:
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
var subject = email.getSubject();
var vendorReferenceNumber = current.u_vendor_reference_number;
if (vendorReferenceNumber) {
email.setSubject(subject + ' | Ticket # ' + vendorReferenceNumber.getDisplayValue());
email.addAddress('cc', 'matt.test@matt.com.au', 'Matt Test');
}
})(current, template, email, email_action, event);
Just keep in mind that the addAddress can only be used to append to the 'cc' or 'bcc' list.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-06-2024 10:42 PM
Even without email sending enabled, you should see the cc'd address in the "Copied" field on sys_email. Is that what you're looking at? You won't see the complete headers if an email isn't sent, so you won't have the "Cc:" line there.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2024 02:38 PM
Perfect. I wasn't looking at this field, I was looking at recipients and headers! Thankyou so much