This page is called from DestinationOptions.csp. It schedules the chosen report
and sends the instance to the destination specified by the user.
<!-- #include file="RetrieveIStore.csp" -->
<!-- #include file=helper_js.csp -->
function ScheduleToFTP(IStore,ReportId, ServerName, AccoutName, UserName, Password, FilePath, Port)
Schedule the report and send the instance to a server via FTP.
var Reports = IStore.Query("SELECT SI_ID, SI_NAME FROM CI_INFOOBJECTS WHERE SI_ID="+ReportId);
//Create an interface to the scheduling options for the report.
ScheduleInfo = Report.SchedulingInfo;
// Get the FTP InfoObject from the APS. Note that the SI_PARENTID will always be 29.
FTP = IStore.Query("Select SI_DEST_SCHEDULEOPTIONS From CI_SYSTEMOBJECTS Where SI_PARENTID=29 and SI_NAME='CrystalEnterprise.FTP'").Item(1);
// Get the actual FTP object and its ScheduleOptions from the FTP plugin.
FTPSchedulingOptions = FTP.PluginInterface("").ScheduleOptions;
// The account name is usually not necessary for some FTP servers.
FTPSchedulingOptions.Account = AccoutName;
FTPSchedulingOptions.ServerName = ServerName;
FTPSchedulingOptions.UserName = UserName;
FTPSchedulingOptions.Password = Password;
FTPSchedulingOptions.DestinationFiles.Add (FilePath);
FTPSchedulingOptions.Port = Port;
// Copy the properties from the FTP object into the report's scheduling
// information. This will cause the file to be transfered via FTP after it has been
ScheduleInfo.Destination.SetFromPlugin (FTP);
//Tell the APS to schedule the report.
function ScheduleToSMTP(IStore,ReportId, DomainName, ServerName, Subject, SenderAddress, RecipientAddresses, Port, Attachment, CCAddresses, Body, Authentication, UserName, Password)
Schedule the report and send the instance to a server via email.
A JavaScript array of strings that contain the recipient addresses, those that will go on the To line.
A JavaScript array of strings that contain the recipient addresses, those that will go on the CC line.
var Reports = IStore.Query("SELECT SI_ID, SI_NAME FROM CI_INFOOBJECTS WHERE SI_ID="+ReportId);
//Create an interface to the scheduling options for the report.
ScheduleInfo = Report.SchedulingInfo;
// Get the SMTP InfoObject from the APS. Note that the SI_PARENTID will always be 29.
("Select SI_DEST_SCHEDULEOPTIONS From CI_SYSTEMOBJECTS Where SI_PARENTID=29 and SI_NAME='CrystalEnterprise.SMTP'").Item(1);
// Get the actual SMTP object and its ScheduleOptions property from the plugin interface.
// It will be empty at this point.
SMTPSchedulingOptions = SMTP.PluginInterface("").ScheduleOptions;
// The domain name is not required for all SMTP servers.
SMTPSchedulingOptions.DomainName = DomainName;
SMTPSchedulingOptions.Subject = Subject;
// Populate the To and CC addresses.
for(k=0;k<RecipientAddresses.length;k++)
SMTPSchedulingOptions.ToAddresses.Add (RecipientAddresses[k]);
for(k=0;k<CCAddresses.length;k++)
SMTPSchedulingOptions.CCAddresses.Add (CCAddresses[k]);
SMTPSchedulingOptions.Port = Port;
SMTPSchedulingOptions.SenderAddress = SenderAddress;
SMTPSchedulingOptions.ServerName = ServerName;
// For the MimeType use the Report object's Mimetype property.
SMTPSchedulingOptions.Attachments.Add(Report.MimeType,Attachment);
SMTPSchedulingOptions.Message = Body;
SMTPSchedulingOptions.SMTPAuthentication=Authentication;
SMTPSchedulingOptions.SMTPUserName = UserName;
SMTPSchedulingOptions.SMTPPassword = Password;
// Copy the SMTP options into the report's scheduling info. This will cause the
// instance to be sent via email after the report has been run.
ScheduleInfo.Destination.SetFromPlugin (SMTP);
//Tell the APS to schedule the report.
function ScheduleToDisk(IStore,ReportId, FilePath)
Schedule the report and cause the instance to be copied to a local or network disk.
var Reports = IStore.Query("SELECT SI_ID, SI_NAME FROM CI_INFOOBJECTS WHERE SI_ID="+ReportId);
//Create an interface to the scheduling options for the report.
ScheduleInfo = Report.SchedulingInfo;
// Get the Disk InfoObject from the APS. Note that the SI_PARENTID will always be 29.
Disk = IStore.Query("Select SI_DEST_SCHEDULEOPTIONS From CI_SYSTEMOBJECTS Where SI_PARENTID=29 and SI_NAME='CrystalEnterprise.DiskUnmanaged'").Item(1);
// Get the actual DiskUnanaged object and its ScheduleOptions.
DiskSchedulingOptions = Disk.PluginInterface("").ScheduleOptions;
DiskSchedulingOptions.DestinationFiles.Add(FilePath);
// Copy the disk options into the report's scheduling options. This will cause the
// report's instance to be copied to the directory.
ScheduleInfo.Destination.SetFromPlugin (Disk);
//Tell the APS to schedule the report.
function ScheduleToPrinter(PrinterName, Copies, FromPage, ToPage)
This function causes the instance of a report to be printed once it has finished
To print all pages set FromPage and ToPage to zero.
var Reports = IStore.Query("SELECT SI_ID, SI_NAME FROM CI_INFOOBJECTS WHERE SI_ID="+ReportId);
//Create an interface to the scheduling options for the report.
ScheduleInfo = Report.SchedulingInfo;
// Get the printer options from the report plugin interface. These can be found
PrinterOptions = Report.PluginInterface("").ReportPrinterOptions;
PrinterOptions.Copies = Copies;
// Enable the printer options otherwise the instance wont print.
PrinterOptions.FromPage = FromPage;
PrinterOptions.ToPage = ToPage;
// This name must be the actual name of the printer. Note that on Windows, in some cases,
// the name displayed in the properties page of the printer is not the full printer name.
PrinterOptions.PrinterName = PrinterName;
//Tell the APS to schedule the report.
Depending on the destination that the user specified, get the options and schedule the
Response.Redirect("Start.csp");
// Since the Request object does not give back a string, cast it.
ReportId = String(Request.QueryString.Item("ReportId"));
Destination = String(Request.QueryString.Item("Destination"));
ServerName = Request.Form.Item("ServerName");
// In this case, since we want a number, we must first convert the item
Port = Number(String(Request.Form.Item("Port")));
AccountName = Request.Form.Item("AccountName");
UserName = Request.Form.Item("UserName");
Password = Request.Form.Item("Password");
FilePath = Request.Form.Item("FilePath");
ScheduleToFTP(IStore,ReportId, ServerName,AccountName,UserName,Password,FilePath,Port);
ServerName = Request.Form.Item("ServerName");
Port = Request.Form.Item("Port");
DomainName = Request.Form.Item("DomainName");
RecipientAddresses = String(Request.Form.Item("RecipientAddresses")).split(";");
SenderAddress = Request.Form.Item("SenderAddress");
Subject = Request.Form.Item("Subject");
CCAddresses = String(Request.Form.Item("CCAddresses")).split(";");
Attachment=Request.Form.Item("Attachment");
Body=Request.Form.Item("Body");
Authentication = Number(Request.Form.Item("AuthenticationMethod"));
UserName = Request.Form.Item("UserName");
Password = Request.Form.Item("Password");
ScheduleToSMTP(IStore,ReportId,DomainName,ServerName,Subject,SenderAddress,RecipientAddresses,Port, Attachment, CCAddresses, Body, Authentication, UserName, Password);
FilePath = Request.Form.Item("FileName");
ScheduleToDisk(IStore,ReportId,FilePath);
PrinterName = Request.Form.Item("PrinterName");
FromPage = Request.Form.Item("FromPage");
ToPage = Request.Form.Item("ToPage");
Copies = Request.Form.Item("Copies");
ScheduleToPrinter(PrinterName,Copies,FromPage,ToPage);
Crystal Decisions, Inc. http://www.crystaldecisions.com Support services: http://support.crystaldecisions.com |