How can I add BCC to a group, when create/run Scheduled Report ?

MR Carvalho
Tera Contributor

 

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.

 

 

 

 
4 REPLIES 4

msd93
Kilo Sage

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.

Ankur Bawiskar
Tera Patron
Tera Patron

@MR Carvalho 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@MR Carvalho 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Revanth Karra
Tera Expert

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

  1. Create a new mail script.
  2. 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

  1. Create a new notification rule.
  2. In the notification rule, select the Email notification type.
  3. In the To field, enter the email address of the group that you want to send the email to.
  4. In the BCC field, enter the email address of the group that you want to send the email as BCC.
  5. Save the notification rule.
  6. Open the scheduled report that you want to send the email as BCC to a group.
  7. In the Notification section, select the notification rule that you created in step 1.
  8. 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