Scheduled Report Email Addresses

michaelmassey
Giga Contributor

I have created a report that I want to schedule. Creating the report and scheduling is working fine, but I want to create a dynamic list of Email Addresses to send the report to each time it runs. I am trying to put javascript in the Email Addresses field on the Scheduled Email of Report record but it does not seem to work. Has anyone used this field and then called a Script Includes to build a dynamic list of email addresses? Is there another way of scheduling the report and creating a dynamic list of email addresses to send it to? Thanks.

8 REPLIES 8

amiharia
Kilo Contributor

I think this documentation might work for you - http://wiki.servicenow.com/index.php?title=Scripting_for_Email_Notifications


michaelmassey
Giga Contributor

amiharia,

Thanks for the response. That might have worked. I have already implemented with a workaround of sending it to an Outlook Distribution List. That works for us and then the Service Desk Supervisor manages that list.

Thanks,
Michael


Am trying to schedule my reports to my Company Outlook Distribution list but it never works. Scheduled is report is sent to myself and DL. Though the report that I receive contains the DL in the TO but my fellow peers do not receive it. Any idea Please?

Am in Service Now Orlando version and am not an admin

Jake Gillespie
Mega Guru

You can add javascript to the Scheduled Email Report, but you first need to create a script include.

1) Create a client-callable script include (e.g 'ReportEmailList') and enter the following script:
// Script to return a comma separated list of email recipients
function getReportRecipients(){
var email_recipients = "";
email_recipients += "email1@email.com";
email_recipients += ",email2@email.com";
email_recipients += ",email3@email.com";

return email_recipients;
}

(modify this code to produce a comma separated list of your recipients)

2) Tick the 'conditional' box on the Scheduled Email Report form and enter the following script:
// Include the Script Include
gs.include('ReportEmailList');
// Call the function to provide comma separated email recipients
var email_recipients = getReportRecipients();
// Add recipients to the scheduled report's recipients
current.address_list = email_recipients;
// Need to set this true for condition script to run
answer = true;