Is there anyway in a scheduled report from Servicenow to send to to a BCC distribution list?

chasspaugh
Kilo Contributor

Is there anyway in a scheduled report from Servicenow to send to to a BCC distribution list? I see where you can activate the E-mail client to e-mail from Incidents etc with BCC but no mention of reporting and I certainly do not see the option when I am scheduling reports.

6 REPLIES 6

chasspaugh
Kilo Contributor

Guessing the answer is no since I seen no feedback on this.


It's a great idea and should be possible



if not it needs to go on the backlog !


Steve McCarty
Mega Guru

I haven't seen a way to do it directly, but you can attach a report to a custom email notification and have a mail script that adds addresses to the bcc field.   To make it work you need to create a new event in the events registry.   The only thing you need to fill in here is an event name (I called mine: spm.sendreport).   Next you need to create an email notification.   You will need to activate the advanced view so that you can change the Send when field to "Event is fired".   Then choose your event name in the Event Name field.


  Capture.PNG



On the What it will contain tab you will need to put these two lines:


        ${mail_script:mail_script_name}


        ${report:reportID:sys_id_of_report}


somewhere in the body of your message.   Change mail_script_name and sys_id_of_report to the name of your mail script that you are about to create and the sys_id of the report you want to send.   You can add whatever other text you want to be included in the message body.



Next you need the mail script to add the bcc fields.   Go to the Notification Email Scripts module and create a new email script.   Make sure the name matches what you put in the body of your email.   You can use any server side scripting you want to generate a list of users, but the key line you need is:


        email.addAddress('bcc','email_address,'display_name');


You can run that as many times as you want to add as many email addresses as you like.   Just change the email_address and display_name to what you need.



The last piece is to create a schedule job that triggers the event to fire off the notification.   So go to System Definition -> Scheduled Jobs and hit the New button.   Click the link to "Automatically run a script of your choosing".   Give it a name, choose whatever schedule you want, and then add the following line to the "Run this script" field:


        gs.eventQueue('spm.sendreport', null, null, null);


Change 'spm.sendreport' to whatever you called your event in the event registry.



If you want to get fancier, you can generate the list of email addresses from the scheduled job and pass them as parameters to your event or even send the sys_id of your report in one of the parameters so that you can use the same notification to send different reports from different jobs.



So all that isn't as easy as just picking some users out of a list and adding them to the "To:" field on the scheduled report, but if you really want to send it to a BCC list, this will get it done.



-Steve


Thanks guys.. it should be easier but at least now I have a solution


On Mar 25, 2016 6:53 PM, "dtcsteve" <community-no-reply@servicenow.com>