How can I add BCC to a group, when create/run Scheduled Report ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 09:29 AM
Hi guys,
I created a Scheduled Report. But now I want send the email as BCC to a group, is that possible?
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 12:19 AM
Hi @MR Carvalho
Try below steps:
1) Create a Scheduled Report in ServiceNow without specifying the BCC recipient.
2) Create a Scheduled Script Execution in ServiceNow to run a script that sends the report via email with the BCC recipient included.
// Define the BCC recipient's email address
var bccRecipient = 'example@example.com';
// Get the report data (You need to replace 'reportSysId' with the actual Sys ID of your report)
var reportSysId = 'YOUR_REPORT_SYS_ID';
var report = new GlideRecord('sys_report');
if (report.get(reportSysId)) {
// Configure email parameters
var email = new GlideEmailOutbound();
email.setSubject('Your Report Subject');
email.setBody('Your report message.');
// Add the BCC recipient
email.addBcc(bccRecipient);
// Attach the report as an attachment (You may need to customize this)
var reportContent = report.getEncodedQuery();
email.addAttachment(new GlideEmailAttachment('report.csv', reportContent, 'text/csv'));
// Send the email
email.send();
} else {
gs.log('Report not found with Sys ID: ' + reportSysId);
}
Hope this helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 12:31 AM
check this link
How can I add BCC, CC when create/run Scheduled Report ?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 08:08 PM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 09:31 PM - edited 09-21-2023 09:34 PM
Dear MR Carvalho,
@MR Carvalho , hope you're doing great!
It is possible to send a scheduled report email as BCC to a group. There are two ways to do this:
Method 1:
Using a mail script
- Create a new mail script.
- In the mail script, add the following code:Save the mail script.
var group = "group name";
email.addAddress("bcc", group);
3. Open the scheduled report that you want to send the email as BCC to a group.
4. In the Notification section, click the Add Notification button.
5. Select the mail script that you created in step 2.
6. Save the scheduled report.
Method 2:
Using a notification rule
- Create a new notification rule.
- In the notification rule, select the Email notification type.
- In the To field, enter the email address of the group that you want to send the email to.
- In the BCC field, enter the email address of the group that you want to send the email as BCC.
- Save the notification rule.
- Open the scheduled report that you want to send the email as BCC to a group.
- In the Notification section, select the notification rule that you created in step 1.
- Save the scheduled report.
NOTE:
If you need to send the email to multiple groups as BCC, then you should use the mail script method. If you need to send the email to a single group as BCC, then you can use either the mail script method or the notification rule method.
Please take a look to the below important points to be followed!
- If you are using the mail script method, you can also add additional email addresses to the BCC field of the email. To do this, simply add additional
email.addAddress("bcc", emailAddress);
statements to the mail script.
- If you are using the notification rule method, you can also add additional email addresses to the BCC field of the email. To do this, simply add additional email addresses to the BCC field of the notification rule.
- You can also use the mail script method or the notification rule method to send the scheduled report email to multiple groups as BCC and to a single group as BCC. To do this, simply add the email addresses of the groups to the BCC field of the mail script or notification rule.
Kindly, please mark my solution as Helpful/Correct, if applicable. If I could help you with your Query then, please hit the Thumb Icon and mark as Correct!!
Thanks & Regards,
Revanth. K
Product Test Automation Engineer